IT lexicon › Hardware › Logarithmic depth buffer

Logarithmic depth buffer

Hardware På svenska → Updated: 2026-10-26

Storing depth on a logarithmic scale so precision lasts across the whole view, from centimetres up close to kilometres away.

An ordinary z-buffer inherits the perspective projection's skew: almost all precision lands next to the camera and almost none at the far plane, giving z-fighting in the distance. A logarithmic depth buffer instead writes depth as the logarithm of distance in the fragment shader, which evens out resolution over enormous ranges — indispensable in planetary and space renderers where the scale spans orders of magnitude.

The cost is that depth must be written per fragment (gl_FragDepth), which defeats early-z rejection unless handled carefully, and the value does not interpolate linearly across a triangle. The technique became popular in WebGL space simulators during the 2010s. The alternative, reverse-Z, solves the same problem at almost no cost and has largely taken over where the hardware allows it.

← Back to the lexicon