i
i
i
i
i
i
i
i
674 14. Acceleration Algorithms
much it can occlude. As an example, a matchbox can occlude the Golden
Gate Bridge if the viewer is sufficiently close to the matchbox.
14.6.1 Hardware Occlusion Queries
Modern GPUs support occlusion culling by using a special rendering mode.
5
Simply put, the user can query the hardware to find out whether a set of
polygons is visible when compared to the current contents of the Z-buffer.
These polygons most often form the bounding volume (for example, a box
or k-DOP) of a more complex object. If none of these polygons are visible,
then the object can be culled. The implementation in hardware rasterizes
the polygons of the query and compares their depths to the Z-buffer. A
count of the number of pixels n in which these polygons are visible is gen-
erated, though no pixels are actually modified. If n is zero, all polygons
are occluded (or clipped). Therefore, the occlusion queries operate in im-
age space. Similar queries are used by the hierarchical Z-buffer algorithm
(Section 14.6.2).
If the pixel count n = 0, and the camera’s position is not inside the
bounding volume,
6
then the entire bounding volume is completely occluded,
and the contained objects can safely be discarded. If n>0, then a fraction
of the pixels failed the test. If n is smaller than a threshold number of
pixels, the object could be discarded as being unlikely to contribute much
to the final image [1360]. In this way, speed can be traded for possible loss of
quality. Another use is to let n help determine the LOD (see Section 14.7) of
an object. If n is small, then a smaller fraction of the object is (potentially)
visible, and so a less detailed LOD can be used.
When the bounding volume is found to be obscured, we gain per-
formance by avoiding sending the complex object through the rendering
pipeline. However, if the test fails, we actually lose a bit of performance as
we spent additional time testing this bounding volume to no benefit.
With such techniques, performance has been reported to be up to twice
as fast as rendering that does not use any occlusion culling [1143]. For
large city scenes or building interiors, gains could be even higher.
The latency of a query is often a relatively long time; often, hundreds or
thousands of polygons can be rendered within this time (see Section 18.3.5
5
This type of hardware support was first implemented on a Kubota Pacific Titan
3000 computer with Denali GB graphics hardware [450].
6
More precisely, no part of the camera frustum’s visible near plane should be inside
the bounding volume. For orthographic views, used in CAD applications, the camera is
normally fully outside of all objects, so this is not a problem. For perspective viewing,
this near-plane case is important. One solution is to be conservative, never testing such
bounding volumes for occlusion.