Game Development Reference
In-Depth Information
Figure 4.16 Overlapping triangles failure case.
The answer is that there is no one triangle that is furthest back. In this instance, the
only way the painter's algorithm would be able to draw these triangles properly is
if some of them were split into multiple triangles.
Because of all these issues, the painter's algorithm does not see much use in 3D
games.
Z-Buffering
In z-buffering , an additional memory buffer is used during the rendering process.
This extra buffer, known as the z-buffer , stores data for each pixel in the scene,
much like the color buffer. But unlike the color buffer, which stores color inform-
ation, the z-buffer (also known as the depth buffer ) stores the distance from the
camera, or depth , at that particular pixel. Collectively, the set of buffers we use to
represent a frame (which can include a color buffer, z-buffer, stencil buffer, and so
on) is called the frame buffer .
At the beginning of a frame rendered with z-buffering, the z-buffer is cleared out
so that the depth at each pixel is set to infinity. Then, during rendering, before a
pixel is drawn, the depth is computed at that pixel. If the depth at that pixel is less
Search WWH ::




Custom Search