Next: 2.3.2 The Stencil Buffer Up: 2.3 Ancillary Buffers Previous: 2.3 Ancillary Buffers

2.3.1 The Depth Buffer

For 3D graphics, the depth buffer (also commonly referred to as a Z buffer) is nearly essential. While the screen only has two dimensions, 3D graphics seeks to simulate a third. When 3D primitives are rendered, they are rasterized into a collection of fragments. Each fragment corresponds to a single pixel and includes color, depth, and sometimes texture-coordinate values. The X and Y values for a fragment determine where on the screen the pixel should appear. A fragment's Z value or depth is used to determine how ``near'' the fragment is. When the depth buffer is enabled, the fragment is drawn only if its Z value is ``nearer'' than the current Z value for the corresponding pixel in the depth buffer. When the fragment is drawn into the frame buffer, its Z value replaces the previous value in the depth buffer. Normally, when the scene starts to be rendered, the entire depth buffer is cleared to the ``farthest'' value. As a 3D scene is rendered, the depth buffer automatically sorts the fragments being drawn so only the nearest fragment at each pixel location gets drawn. Things logically behind other things are automatically eliminated from the scene. This is the normal use for a depth buffer, although other uses are possible.


mjk@asd.sgi.com
Wed Oct 19 18:06:42 PDT 1994