Part IA Michaelmas Term
Z-Buffer Algorithm
Hidden Surface Removal
Multiple triangles may cover the same pixel. We need to determine which surface is closest to the camera.
Z-Buffer
The Z-buffer (depth buffer) stores the depth value for each pixel.
Algorithm
Initialise:
colour(x, y) = background_colour
depth(x, y) = z_max // far clipping plane
For each triangle:
For each fragment (x, y):
Calculate z for current (x, y)
if (z < depth(x, y)) and (z > z_min):
depth(x, y) = z
colour(x, y) = fragment_colour(x, y)
Z-Buffer Precision
Typically 24 or 32 bits. Often stores instead of for better precision distribution.
Why ?
Perspective transformation makes non-linear in screen space. Interpolating gives correct results.
Z-Fighting
When two surfaces are nearly coplanar, limited precision causes Z-fighting: pixels from both surfaces appear randomly.
Solutions:
- Increase depth buffer precision
- Move surfaces slightly apart
- Use polygon offset
Summary
- Z-buffer stores depth for each pixel
- Update pixel only if new fragment is closer
- Store for better precision distribution
- Z-fighting occurs when surfaces are nearly coplanar
Past Paper Questions
2025 Paper 3 Question 4(b)(i): In rasterisation, what information does the Z-buffer store? Why is this information needed, and how is it computed? [3 marks]
2024 Paper 3 Question 3: Explain the Z-buffer algorithm. What happens when two surfaces are at the same depth?