- Asked 7/25
- 2076 Asoj · 8 marks
- 2070 Asar · 8 marks
- 2072 Chaitra · 6 marks
- 2073 Shrawan · 4 marks
- 2069 Chaitra · 7 marks
- 2078 Bhadra · 6 marks
- 2067 Mangsir (old course) · 6 marks
Z-buffer (depth buffer) method
Short answer
Z-buffer stores nearest depth per pixel; depth is computed as z = (−Ax−By−D)/C. Incrementally along a scan line, depth updates as z' = z − A/C; if new depth is less than stored, the pixel is replaced in the frame buffer.
Explain the Z-buffer (depth buffer) method of visible surface detection, including how the depth of pixels is calculated.
The Z-buffer (depth-buffer) method is an image-space method. It compares the depth (z value) of surfaces at each pixel position (x, y) of the projection plane and keeps the nearest one.
Two buffers
- Depth buffer zbuf(x, y): depth of the nearest surface found so far at each pixel.
- Frame (refresh) buffer frame(x, y): colour of the nearest surface at each pixel.
Viewing is along the z-axis, with 0 ≤ depth ≤ 1 (0 = front plane, 1 = back plane).
Algorithm
1. Initialise zbuf(x,y) = 1 (maximum depth), frame(x,y) = background colour for all x,y.
2. For each polygon in the scene:
for each pixel (x,y) of its projection:
compute depth z of the polygon at (x,y)
if z < zbuf(x,y):
zbuf(x,y) = z
frame(x,y) = surface colour at (x,y)
3. After all polygons are done, the frame buffer holds the visible image.
Depth calculation. For a plane Ax + By + Cz + D = 0:
z = (−Ax − By − D) / C
Incremental calculation (faster): when we move one pixel to the right along a scan line, x becomes x + 1, so
z' = (−A(x+1) − By − D)/C = z − A/C
(A/C is a constant for the polygon). Moving down to the next scan line along an edge with slope m (x' = x − 1/m, y' = y − 1):
z' = z + (A/m + B)/C
For a vertical edge, z' = z + B/C.
Features: the method is simple, handles any shape, needs no sorting, and polygons may be processed in any order. However, it needs extra memory for the depth buffer, cannot render transparent surfaces, and suffers from aliasing.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Scan-line method of visible surface · Computer Graphics, chapter 7 · asked 3×
- Z-buffer method with limitation · Computer Graphics, chapter 7 · asked 3×
- A-buffer method · Computer Graphics, chapter 7 · asked 2×
- VSD factors, classes, Z/A-buffer · Computer Graphics, chapter 7
- Raster display and frame buffer load time · Computer Graphics, chapter 1
- Compare Z-buffer, A-buffer; scan-line · Computer Graphics, chapter 7
- Control of sub-surface water and seepage · Transportation Engineering I, chapter 4 · asked 15×
- Surface drainage design, 40 ha Terai field · Irrigation and Drainage Engineering, chapter 9
- Water surface over hump with contraction · Hydraulics, chapter 7
- Flow rate from drop in surface over hump · Hydraulics, chapter 7