Memory layer storing depth values per pixel in 3D rendering — determines which geometry occludes what. Foundation of correct depth sorting in real-time graphics.
You're sitting in compositing, wondering why your 3D renders suddenly look jumbled — objects are overlapping incorrectly, what should be in front is behind. The Z-buffer is your tool against this. It stores the depth coordinate for each pixel — the distance to the camera — and thus decides in real-time which geometry remains visible and which is occluded. Without this memory area, the 3D engine wouldn't know if one cube is in front of or behind another.
In practice, it works like this: while the GPU renders your scene, it stores not only the color for each pixel but also its Z-value — the depth. If a new pixel hits the same position, the engine compares its Z-depth with the stored value. Only if the new pixel is closer to the camera is it written. This is the depth test, and it runs millions of times per frame. You don't notice it because it's incredibly fast — but without a Z-buffer, you'd have to manually sort which layer is on top every time. A nightmare.
On the set of VFX production, you need the Z-buffer as a depth pass or Z-depth pass. This is a separate render layer that visualizes depth values instead of colors — bright for near, dark for far. In compositing, you can use it to achieve depth of field, realistically blend in volumetrics, or make keying more precise. Many renderers now store Z-buffers as 32-bit or 16-bit channels — the higher, the more subtle the gradations, the less banding in your bokeh.
A stumbling block: Z-fighting occurs when two geometries have exactly the same depth. Then the Z-buffer flickers back and forth between the two objects — an annoying glitch. Avoidable through small offset values or correct polygon arrangement. If you're working with volumetrics or transparent objects, you also need to know that Z-buffers only work with the classic depth test — some effects require Order-Independent Transparency (OIT), a different algorithm that solves transparency problems more elegantly.