LearnViz CompSci
Home / Learn / Graphics, Vision & Media / Z-Buffer

Intermediate Topic 21 of 49 Graphics, Vision & Media

Z-Buffer

Per-pixel depth test resolving visibility.

How it works

The Z-buffer, or depth buffer, stores a depth value for every pixel, so the renderer can decide which surface is closest. When a fragment is drawn, its depth is compared with the stored value: if closer, it overwrites color and depth; otherwise it is discarded. This resolves hidden-surface removal without sorting triangles, in any draw order. Depth is stored non-linearly after perspective projection, with more precision near the camera, and formats are typically 24 or 32 bits.

Where it is used

All real-time 3D engines use depth buffers, and techniques such as shadow mapping, depth of field and screen-space effects reuse depth information.

Common pitfall

Z-fighting occurs when two surfaces are nearly coplanar or far from the camera and precision is insufficient, causing flickering. Transparent objects need sorting because depth writes block objects behind them. A near plane too close to the camera wastes precision. Use reversed-z with floating-point depth, tighten the near and far range and offset decals with depth bias.

Where it fits in the course

Z-Buffer is topic 21 of 49 in Graphics, Vision & Media, rated Intermediate. It follows Rasterization. The next topic is Shading Models.

Practice and explore

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the Graphics, Vision & Media quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is Z-Buffer?
Per-pixel depth test resolving visibility. It belongs to Graphics, Vision & Media and is an intermediate-level topic.
Where do people use Z-Buffer?
All real-time 3D engines use depth buffers, and techniques such as shadow mapping, depth of field and screen-space effects reuse depth information.
What is the most common mistake with Z-Buffer?
Z-fighting occurs when two surfaces are nearly coplanar or far from the camera and precision is insufficient, causing flickering.
What should I learn before this topic?
Start with Rasterization, the topic just before it in Graphics, Vision & Media.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Graphics, Vision & Media quiz.
Is Z-Buffer hard to learn?
It is an Intermediate topic. Be comfortable with the Beginner topics in this area first, then read the common pitfall carefully, since it is where most mistakes happen.
How long does it take to learn Z-Buffer?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Z-Buffer?
Rasterization, Shading Models, Rendering Pipeline are closely connected. The full list is in the related topics section of this page.
What should I study after Z-Buffer?
Continue with Shading Models, the next topic in Graphics, Vision & Media.

Related topics