Skip to content
Rendering

Depth Buffer

Per-pixel distance used to sort what is visible

Also known as: Z-buffer · Z buffer · Depth map · Scene depth · Reverse-Z · Depth precision

Definition

The depth buffer, or Z-buffer, is an image that stores the distance from the camera to the nearest surface at every pixel. When a new surface is drawn, the GPU compares its depth to the stored value and keeps only the closer one, which is how objects hide each other without sorting. The depth buffer is also used by effects such as depth of field, fog, ambient occlusion and soft particles. Its precision is limited, which causes z-fighting when two surfaces are very close.

In production

Keep the near and far clip planes as close together as the scene allows, since a very small near plane and a huge far plane waste precision and cause flickering distant surfaces. Do not place two surfaces on the same plane, such as a decal over a wall, without an offset. Translucent surfaces usually do not write depth, which is why they sort poorly. Modern engines use reversed depth to improve precision.

Tools that use Depth Buffer

See also