# What is a shader?

> A shader is a small GPU program for one pipeline stage, such as vertices or fragments, not a material slider.

Source: https://fullbytedeveloper.com/blog/what-is-a-shader
Published here: 2026-12-03, updated 2026-12-03

A shader is a user-defined program that runs on a stage of a graphics processor [1]. It fills programmable parts of the rendering pipeline, and in a limited form can do general GPU compute [1]. Related: [what is a game loop](/blog/what-is-a-game-loop), [how Blender Cycles renders](/blog/how-blender-cycles-renders).

## Quick start (under a minute)

Pick one stage and one job:

1. **Vertex shader:** move each input vertex (transform to clip space) [1].
2. **Fragment shader:** pick the color of each rasterized pixel sample [1].
3. **Compute shader:** run a 3D grid of work groups for off-pipeline math [1].

You do not need a game installed to learn the model. You need to know which stage owns which inputs.

## From draw call to pixel color

<figure aria-label="Vertex shader to fragment shader GPU stages">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 220" role="img" aria-hidden="true">
  <defs>
    <marker id="whatisashader-sh-arr" markerWidth="8" markerHeight="8" refX="7" refY="4" orient="auto">
      <path d="M0,0 L8,4 L0,8 Z" fill="#14b8a6"/>
    </marker>
  </defs>
  <rect x="0" y="0" width="360" height="220" rx="12" fill="#0b1f3a"/>
  <rect x="15.4286" y="82.5" width="46.2857" height="55" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="0.964286"/>
  <text x="38.5714" y="108" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">CPU</text>
  <text x="38.5714" y="122" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">draw [2]</text>
  <rect x="77.1429" y="62.5" width="61.7143" height="95" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="1.28571"/>
  <text x="108" y="96" text-anchor="middle" font-size="12" font-weight="600" fill="#e6edf7" font-family="system-ui,sans-serif">vertex</text>
  <text x="108" y="112" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">shader [1]</text>
  <rect x="159.429" y="82.5" width="56.5714" height="55" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="0.771429"/>
  <text x="187.714" y="108" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">rasterizer</text>
  <text x="187.714" y="122" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">fixed [2]</text>
  <rect x="236.571" y="62.5" width="61.7143" height="95" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="1.28571"/>
  <text x="267.429" y="96" text-anchor="middle" font-size="12" font-weight="600" fill="#e6edf7" font-family="system-ui,sans-serif">fragment</text>
  <text x="267.429" y="112" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">shader [1]</text>
  <rect x="313.714" y="82.5" width="36" height="55" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="0.964286"/>
  <text x="331.714" y="108" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">frame</text>
  <text x="331.714" y="122" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">buffer</text>
  <line x1="61.7143" y1="110" x2="74.5714" y2="110" stroke="#14b8a6" stroke-width="0.964286" marker-end="url(#whatisashader-sh-arr)"/>
  <line x1="138.857" y1="110" x2="156.857" y2="110" stroke="#14b8a6" stroke-width="0.964286" marker-end="url(#whatisashader-sh-arr)"/>
  <line x1="216" y1="110" x2="234" y2="110" stroke="#14b8a6" stroke-width="0.964286" marker-end="url(#whatisashader-sh-arr)"/>
  <line x1="298.286" y1="110" x2="311.143" y2="110" stroke="#14b8a6" stroke-width="0.964286" marker-end="url(#whatisashader-sh-arr)"/>
</svg>
</figure>

The OpenGL wiki calls each shader an independent program compiled for a specific stage [1]. A **program object** links one or more stage binaries; each **shader object** still targets a single stage [1].

## Name the programmable stages

The wiki's stage list is the usual teaching map [1]:

| Stage | Typical frequency [1] |
| --- | --- |
| Vertex | Once per input vertex (subject to post-transform cache behavior) |
| Tessellation control / evaluation | Around patches when tessellation is enabled |
| Geometry | Once per primitive that reaches the stage |
| Fragment | Once per fragment generated by the rasterizer |
| Compute | Once per invocation in a dispatched 3D grid |

Fixed-function steps (rasterization, depth test, blending) sit between your shaders [2]. You do not rewrite rasterization in GLSL; you feed it well-formed clip-space output.

## Think invocations, not one big script

When you draw indexed geometry, the bound program runs. Each stage executes **invocations**: parallel copies of the same instructions on different data [1]. Invocations in a stage generally cannot talk to each other, with documented exceptions inside certain stages [1].

That SIMD-style layout is why a GPU chews through millions of vertices or fragments per frame, and why **divergent branches** (half the lanes take `if`, half take `else`) can stall throughput [1]. The CPU game loop in [what is a game loop](/blog/what-is-a-game-loop) still owns when draws happen; the GPU owns how fast invocations run once submitted.

Uniforms and storage buffers supply data that is **shared** across invocations (camera matrix, elapsed time, texture handles). Per-vertex attributes vary per invocation at the vertex stage. Varyings pass interpolated values from vertex to fragment (texture coordinates, normals).

## Worked example: one fragment's color by hand

The Book of Shaders introduces a minimal fragment idea: map normalized coordinates to RGB [3]. Take one fragment whose interpolated UV is `(0.25, 0.75)` before gamma. A teaching shader might compute:

```text
R = u = 0.25
G = v = 0.75
B = 0.20   (constant accent)
```

**Observed result on paper (draft host, 2026-12-03):** sRGB-ish display would show a blue-green pixel with more green than red. No GPU was required to verify the arithmetic; the numbers are the output of the assignment rules [3].

In real GLSL or WGSL you would write that in a `main()` for the fragment stage and let millions of other fragments run the same logic on their own `(u,v)` [1] [3]. The Book of Shaders runs the same pattern in the browser; this page keeps the math explicit so the stage job stays clear.

## Vertex shader job in one paragraph

A vertex shader reads attributes (position, normal, UV), multiplies by model-view-projection matrices supplied as uniforms, and writes `gl_Position` (or the API's equivalent) [1] [2]. It may also write varyings for the fragment stage. It does **not** know final pixel colors; it only positions primitives for the rasterizer.

## Fragment shader job in one paragraph

After rasterization, the fragment shader receives interpolated varyings plus the fragment's screen position [2]. It samples textures, evaluates lighting models, or applies post tricks. Its outputs feed the framebuffer and depth buffer. Transparency and blending interact with fixed-function state you set from the CPU side [2].

## Compute shaders off to the side

Compute shaders are still "shaders" in the Khronos sense but sit outside the triangle pipeline [1]. You dispatch a 3D grid of work groups for tasks like blur, particle update, or culling. Game loops often interleave compute dispatches with graphics passes on modern APIs.

## Realtime shaders vs path tracing

Realtime shaders approximate light under a frame budget. Blender Cycles path-traces many light samples offline ([how Blender Cycles renders](/blog/how-blender-cycles-renders)). Same vocabulary (materials, light), different loops and time budgets. Shaders are how interactive engines stay inside 16 ms targets while still showing plausible surfaces.

## Uniforms, textures, and binding order

From the CPU side you bind a program, set uniform values (matrices, light direction), attach texture units, then issue a draw [1] [2]. The GPU does not automatically see your host language struct layout; each API names handles and slots explicitly. A common bug is uploading a projection matrix while the wrong program is active, which sends every vertex off screen until you re-bind and redraw.

Texture sampling in the fragment stage reads filtered texels from 2D or cube maps [2]. Mipmaps reduce shimmer on minified surfaces. You still pay for overdraw when transparent fragments stack. That is why UI and particles often get separate passes and sort keys in engines ([what is a game loop](/blog/what-is-a-game-loop)).

## Do not do these

Calling every material knob a "shader" when only the GPU program is the shader.

Writing fragment code that assumes a single pixel runs alone; forgetting millions of parallel invocations share the same source.

Ignoring varyings and doing heavy matrix work per fragment that belongs in the vertex stage.

Expecting the fragment shader to fix bad topology or bad UVs the vertex stage already baked in.

Treating compute and graphics as interchangeable without measuring sync and bandwidth costs.

"shader languages" are identical across OpenGL, Vulkan, Metal, and WebGPU; the stage model transfers, syntax does not.

Change one uniform, recompile, and watch whether the artifact is stage logic or artist parameters. The CPU side that submits draws lives in [what is a game loop](/blog/what-is-a-game-loop); device roles in [CPU vs GPU vs NPU vs TPU](/blog/cpu-vs-gpu-vs-npu-vs-tpu) explain why invocations scale the way they do. When light is sampled offline instead of per frame, [how Blender Cycles renders](/blog/how-blender-cycles-renders) is the cousin pipeline with minutes per pixel instead of milliseconds.

Send this to the friend who thinks a shader is a Photoshop filter for games.

Image: Wireframe cyan cube then solid orange edged cube then ringed funnel then a vertical pane with a teal and orange tile grid, no people.
https://fullbytedeveloper.com/media/what-is-a-shader/what-is-a-shader-venice.webp
Vertex stage positions geometry; fragment stage picks pixel color.

## Sources

1. [Khronos OpenGL Wiki: Shader, accessed 2026-12-03](https://www.khronos.org/opengl/wiki/Shader)
2. [Khronos OpenGL Wiki: Rendering Pipeline Overview, accessed 2026-12-03](https://www.khronos.org/opengl/wiki/Rendering_Pipeline_Overview)
3. [The Book of Shaders: Hello World fragment example, accessed 2026-12-03](https://thebookofshaders.com/02/)
4. [Full Byte Developer: How Blender Cycles renders](https://fullbytedeveloper.com/blog/how-blender-cycles-renders)
5. [Full Byte Developer: What is a game loop](https://fullbytedeveloper.com/blog/what-is-a-game-loop)
6. [Full Byte Developer: CPU vs GPU vs NPU vs TPU](https://fullbytedeveloper.com/blog/cpu-vs-gpu-vs-npu-vs-tpu)
