The z buffer is a technique used in computer graphics programming to determine which objects are "behind" and "in front" of each other in a 3D view, from the eye's perspective. (X and Y are the coordinates on the plane aligned with the front surface, and Z represents the depth.)

The z buffer is a 2D plane, representing the front surface of the 3D viewing cube (the volume in which the graphics image will appear). When you start to draw, you initialize the Z buffer with values representing the distance to the back plane of the cube and the background colour. As objects are drawn, the z value of each pixel to be drawn is compared with the value in the buffer. If the new value is closer to the front, it replaces the old value (colour and distance).

When you're done, you render the buffer as your image. The objects that are closer in the view will appear to eclipse the further objects, which either had their pixels replaced (if they were drawn first) or never put in the buffer at all (if they were drawn second).

This process can also be used to also perform hidden surface removal, as the hidden surfaces will be further away in z order than the visible surfaces. Note that there are more efficient ways to eliminate hidden surfaces prior to rendering.

Log in or register to write something here or to contact authors.