248 III Bending the Pipeline
sent to GPU
Vertex and geometry
GL backface culling
and primitives clipping
Figure 18.1. Culling stages combined.
Most of the time, a developer will ap-
ply all three categories simultaneously (see
Moving from stage to stage introduces
additional computational cost. Culling
unnecessary input as early as possible
yields the highest efﬁciency. This chap-
ter introduces one of the ways to use
the depth buffer for culling whole objects
while drawing. The method is known
as hierarchical depth culling (alternatively,
occlusion culling). It combines differ-
ent levels of the rendering pipeline for
the common goal of discarding invisible
primitives. These levels include: frame-
buffer for the depth buffer, spatial level
for bounding volumes, and the render-
ing sequence for the early depth pass.
The chapter presents a core OpenGL 3.0
implementation of the hierarchical depth
culling pipeline performed with minimal
The pipeline (see Figure 18.2) can be expressed in the following short steps:
• Obtain the depth buffer of occluders (may be the whole scene).
• Construct depth mipmaps.
• Update objects’ bounding boxes.
• Perform depth culling of the bounding boxes.
• Draw the scene using culling results.
This sequence does not mention DMA memory transfers, such as retaining
culling results in the system memory or debugging during the stage of drawing
bounding boxes; nor does it specify the exact order of commands, e.g., we may
use the depth buffer of the previous frame for culling. In the latter case, the culling
results would have a one frame delay and therefore would not be exact.
In the following sections, I will describe each stage in detail. The source GLSL
code of a working implementation can be found on the OpenGL Insights website,