All publications
Graphics & Shaders Mastering OpenGL ES 3

Shading the Canvas: Vertex & Fragment Shaders

The two tiny programs that decide where things go and what color they are.

Dec 17, 2023 · 5 min read · Preview
Shading the Canvas: Vertex & Fragment Shaders

Summary

Every pixel on the GPU passes through two small programs: a vertex shader that decides position, and a fragment shader that decides color. This article introduces both in OpenGL ES 3, explaining how they cooperate to turn geometry into the images you see — the conceptual core of the whole series.

Two small programs do all the heavy lifting in real-time graphics. This article introduces the vertex and fragment shaders in OpenGL ES 3 — how they split the work of position and color, and why understanding them unlocks everything else.

Key ideas

  • 01 The vertex shader runs per vertex and computes positions.
  • 02 The fragment shader runs per pixel and computes color.
  • 03 Varyings pass interpolated data from vertices to fragments.
  • 04 Understanding this pair unlocks nearly all real-time graphics.