Ablaufskizze der Grafikpipeline: 3D-Modell aus Dreiecken, danach Vertex-Shader für die Eckpunkte, dann Rasterisierung in Bildpunkte, dann Fragment-Shader für die Farbe, am Ende das fertige Bild auf dem Monitor.

Shader

A shader is a small program that runs on the graphics card and calculates what a pixel or vertex of a 3D scene ultimately looks like. Because millions of these programs run simultaneously, they produce video game graphics, film effects, and today also the computing power for artificial intelligence.

A shader is a very small program that does not run on a computer’s main processor, but on the graphics card. Its task is narrowly defined: it calculates, for a single point of an image, what color and brightness that point gets. Or it moves a single vertex of a three-dimensional object to the right position. That sounds like little, but a screen image consists of several million points. That’s why the graphics card runs the same shader millions of times simultaneously, once for each point. The name comes from the English “to shade”: originally, it was only about drawing surfaces lighter or darker depending on the incidence of light.

Why games without shaders would look flat

Before shaders, graphics cards could only do a fixed list of effects. Manufacturers had lighting and surfaces hard-wired into the hardware. Anyone who wanted something different was out of luck. Since around 2001, graphics cards have been freely programmable. Since then, it is no longer the chip manufacturers who decide how a surface looks, but the developers of a game.

Practically every visual effect known from modern games is a shader. The wet shine of streets in the rain, the shimmer of heat over asphalt, water with waves and reflections, soft shadows, the blur in the background of a scene. None of this is filmed or painted, but calculated in real time, sixty times per second.

There is also an important economic point. Because shaders are freely programmable, the graphics card became a generally usable computing device. This very capability is the reason why companies like Nvidia no longer just sell gaming hardware today. The same computing units now train AI models.

From triangle to finished pixel

A 3D scene consists entirely of triangles. A car tire, a face, a house wall: everything is made up of thousands of small triangles. These triangles pass through several stages in the graphics card until a finished image emerges at the end. The most important shaders sit at two of these stages.

First, the vertex shader works. A vertex is a corner point of a triangle. This shader calculates where the vertex ends up from the perspective of the virtual camera, and can deform it in the process, for example for flowing clothing. After that, the graphics card fills the area between the vertices with pixels. For each of these points, a fragment shader then runs, often also called a pixel shader. It determines the final color: how does the light fall, how does the material shine, what texture lies on top?

The decisive trick is called parallelism. A modern graphics card has several thousand small computing units. Each one executes the same shader code, just with different input data. You can imagine it like a huge hall full of computers that all receive the same short computing instruction. A main processor would be far too slow for something like this, because it can only process a few tasks at once. Shaders are written in dedicated languages such as GLSL or HLSL, which resemble the programming language C.

Compute shaders, AI chips, and the loading bar in the game menu

In everyday life, you notice shaders mainly when something stutters. Many games display a message like “Compiling shaders” at startup. This is because the shader code must first be translated into the machine language of the specific graphics card installed. If this happens only in the middle of the game, the picture briefly stutters. This is exactly what players regularly complain about with PC ports.

In tech news, the term usually appears with an expanded meaning. Besides graphics shaders, there are compute shaders. They don’t draw anything at all, but instead use the graphics card merely as a fast calculator for arbitrary numerical problems. Physics simulations, weather models, and the training of neural networks run this way. When people talk about the “shader units” or “shader cores” of a graphics card, they simply mean the chip’s parallel computing units.

A common misconception is that shaders are image files or ready-made effects to download. They are program code. Anyone who installs a shader pack in Minecraft is not downloading new textures, but new computational instructions for light, water, and shadow. The game stays the same, only the instructions for calculating the image are different.

Related Products

Subscribe free. Unsubscribe the second it sucks.

High-signal news across AI, business, UX, and tech. Every morning.