Computer Graphics - Depth Buffer Test
Depth Buffer (Z-buffer) Test
Algorithm
The following algorithm is taken from here.
We start with setting the depth of each pixel to infinity. d(i, j) = infinity Initialize the color value for each pixel c(i, j) = background color for each polygon, do the following steps : for (each pixel in polygon's projection) { z (depth) of polygon at (x, y) corresponding to pixel (i, j) if (z < d(i, j)) { d(i, j) = z; c(i, j) = color; } }
Example Figure
![]() |
| An example taken from METU CENG Slides |
Z-Fighting
Z-fighting occurs when two planes have the same depth (have the same value in the z-axis) and z-buffer cannot decide which plane is near which one is far. Then the following situation occurs:
This situation may occur also when the depth range [nearest, furthest] is scaled to [0,1]. This is range [0,1] scaling from [near=10, far=50] after projection and viewport transformations.
| Z-fighting in the intersection |
![]() |
| Taken from METU Ceng Slides |
This is range [0,1] scaling from [near=10, far=200] after projection and viewport transformations.
![]() | |
|
More Resources:
https://www.geeksforgeeks.org/z-buffer-depth-buffer-method/
https://en.wikipedia.org/wiki/Z-buffering



Comments
Post a Comment