Definition: The z-buffer (depth buffer) is a memory area of the graphics card. For each pixel, it stores the distance from the camera to the nearest surface. With it, the GPU decides which surface is visible and which is hidden. The z-buffer is standard in almost every form of real-time rendering.

English: Z-Buffer, Depth Buffer
German: Tiefenpuffer, Z-Puffer

How It Works

When the GPU draws a scene, it calculates the depth of each fragment (a pixel candidate). Then the depth test follows:

  1. If the new fragment is closer to the camera than the stored value, the GPU draws it and stores its depth value.
  2. If it is farther back, the GPU discards it.

This gives a correct image, independent of the drawing order. Transparent surfaces are the exception: they must be sorted, because they do not fully hide the background.

Precision: The buffer has a limited resolution, often 24 bit or 32-bit floating point. The precision is not distributed evenly: it is high near the camera and low at a distance. The ratio between the near and the far clipping plane is decisive. If it is too large, the GPU can no longer tell apart surfaces that are very close together, and z-fighting occurs. Solutions are a well-chosen near plane and techniques such as reversed-Z or logarithmic depth.

In WebGL, the depth buffer is created with the drawing context and activated with the depth test. Frameworks such as Three.js or Babylon.js do this automatically.

Depth in AR: In augmented reality, the depth of the real world is initially missing. Without it, a virtual component always appears in front of real objects, even when it should be behind them. For this reason, platforms estimate a depth map of the environment, for example the ARCore Depth API (from camera movement, also without a depth sensor) or ARKit with Scene Depth on devices with LiDAR and with People Occlusion for people. These values go into the depth test, and virtual objects correctly disappear behind real ones.

Relevance in Mechanical Engineering

  • Product viewers and configurators: Hidden internal parts of a machine stay invisible until section or exploded views show them.
  • Large plant models: Halls that are many meters long and small details in the same image put high demands on depth precision.
  • AR in sales and service: A virtual machine that correctly disappears behind a real pillar or an employee looks credible.

Frequently Asked Questions (FAQ)

What is the difference between a z-buffer and a depth map?

The z-buffer is the depth memory during rendering. A depth map is, in general, an image with depth values, for example from an AR camera, and can go into the z-buffer.

Does AR occlusion need a LiDAR sensor?

Not necessarily. The ARCore Depth API estimates depth from the camera movement. With LiDAR, the values are more accurate and more stable.

Documentation: Google ARCore Depth API · Apple ARKit: Occluding virtual content with people