Rasterization and Rendering Pipeline
Domain scope
Rasterization and the Rendering Pipeline tests how primitives become fragments: clipping, viewport mapping, coverage, depth testing, blending, and the programmable stages that replaced fixed-function lighting.
Core rules
- Vertex shader outputs clip-space positions; clipping happens in homogeneous clip space, then NDC and viewport mapping.
- Coverage is decided at pixel centers. Edge functions give signed areas; consistent sign means inside.
- Depth testing uses the depth buffer; early-z can reject fragments before shading only when shaders do not write depth or discard.
- Attributes must be perspective-correct: interpolate attribute/w and 1/w linearly in screen space, then divide.
Worked example
Screen triangle A(0,0), B(4,0), C(0,4), pixel center P(1.5,0.5). Edge function for A to B is (4)(0.5)-(0)(1.5)=2. For B to C: (-4)(0.5)-(4)(-2.5)=8. For C to A: (0)(-3.5)-(-4)(1.5)=6. All are positive, so P is inside. Barycentric weights for (A,B,C) are proportional to (8,6,2), sum 16, giving (0.5,0.375,0.125). These weights combine vertex attributes, with perspective correction if w varies.
Traps that cost marks
- Applying the top-left fill rule inconsistently, causing cracks or double-shaded shared edges.
- Interpolating UVs affinely in screen space and accepting swimming textures.
- Forgetting that blending is order-dependent and needs a defined blend equation.
- Assuming depth range is always [0,1]; OpenGL default is [-1,1].