The Graphics Pipeline
The vertex shader must output clip-space position in gl_Position.
2.1 Overview (OpenGL / Vulkan rasterization pipeline)
Application (CPU): vertex data, textures, uniforms, draw calls
│
▼
┌───────────────────┐
│ Vertex Fetch │ fixed function: reads vertex attributes from buffers
├───────────────────┤
│ VERTEX SHADER │ programmable: transforms each vertex → clip space
├───────────────────┤
│ Tessellation │ optional: TESS CONTROL SHADER → tessellator → TESS EVALUATION SHADER
├───────────────────┤
│ GEOMETRY SHADER │ optional: per-primitive; can emit/discard primitives
├───────────────────┤
│ Primitive assembly, clipping, perspective divide, viewport transform, face culling
├───────────────────┤
│ Rasterization │ fixed function: primitives → fragments, interpolates outputs
├───────────────────┤
│ FRAGMENT SHADER │ programmable: computes color/depth per fragment
├───────────────────┤
│ Per-sample ops │ scissor, stencil test, depth test, blending, write to framebuffer
└───────────────────┘
│
▼
Framebuffer (screen or texture)
Separately: COMPUTE SHADER — general-purpose GPU computation outside the graphics pipeline.
Modern alternative geometry path: TASK/MESH SHADERS (replace vertex/tessellation/geometry stages).2.2 Shader stages
File extension (convention) transform positions, pass data to later stages output patch vertex set tessellation levels position new vertices amplify/modify primitives fragment (pixel sample) output color, depth .task, .mesh Ray tracing (Vulkan)
.rgen, .rchit, .rmiss, .rahit, .rint, .rcall ray tracing pipeline
2.3 Coordinate spaces
The vertex shader must output clip-space position in gl_Position. NDC depth is [-1, 1] in OpenGL (configurable to [0, 1] with glClipControl) and [0, 1] in Vulkan; Vulkan's Y axis points down in NDC.
Object/model space ──(Model matrix)──► World space ──(View matrix)──► View/eye/camera space
──(Projection matrix)──► Clip space ──(÷ w, perspective divide)──► NDC [-1, 1]
──(Viewport transform)──► Window/screen space (pixels)2.4 Rasterization & interpolation
The rasterizer determines which pixels a triangle covers and interpolates vertex shader outputs across the triangle (perspective-correct by default) to produce fragment shader inputs.