Depth Buffering

By default, whenever multiple objects are rendered at the same place in the window, whatever is drawn last will appear on top of the earlier objects.

This is true even if the last object is farther away, and so ought to appear behind the other objects.

Depth buffering (a.k.a. Z-buffering) is a method to make sure that near objects correctly occlude far objects.

Depth buffering works by keeping track of the depth (Z) of every pixel that is drawn. When the graphics card tries to draw a particular pixel, it checks whether the new depth is nearer to the viewer than the old depth. If not, nothing is drawn at that pixel.


next