Graphics Reference
In-Depth Information
10.1.2 Occlusion Queries
One way of completely avoiding buffer readbacks from the GPU is to recast algorithms
to utilize the occlusion query feature available on most current commodity graphics
hardware. When enabled, the occlusion query counts the number of pixels (or, tech-
nically, samples) of a triangle (or other rendering primitives) passing the current set
of active tests (such as depth and stencil tests). Counter size varies among hardware
implementations, from 1 bit upward. Counter overflows are usually saturated to the
maximum value to ensure expected behavior.
Typical intended use for occlusion queries is for the application to render the major
occluders of a scene first. After they have been rendered, for each (complex) detail
object O i an occlusion query is performed for a simple fully encompassing bounding
volume of O i before O i itself is rendered. If the occlusion query says no part of the
bounding volume is visible, O i must be occluded and consequently can be culled
rather than being rendered. When issuing an occlusion query, writes to color, depth,
and stencil buffers are usually disabled to save processing time and to not interfere
with the query (for example, in the case of multiple back-to-back queries).
In OpenGL, for example, an occlusion query core feature is provided as of
version 1.5 [Segal03]. This feature supports a test that returns the number of sam-
ples of the occlusion-tested geometry passing stencil and depth tests. It also allows
several outstanding occlusion queries, which greatly increases the opportunity for
parallelism between CPU and GPU by minimizing stalls otherwise caused by wait-
ing for an occlusion query to finish. In earlier versions of OpenGL, occlusion
queries are supported through the vendor-specific extensions HP_occlusion_test
and NV_occlusion_query .
In addition to helping to solve visibility problems, occlusion queries are effective
for determining if two convex objects are intersecting. Such a test is explored in the
next section.
10.2 Testing Convex Objects
Several treatments have been forwarded for GPU-assisted collision detection for con-
vex objects; for example, by [Myszkowski95] and [Baciu99]. The basic idea behind
these methods is to consider each render buffer pixel as a ray, perpendicular to the
viewplane, cast toward the objects. When the ray intersects an object, the intersec-
tion can be described as an interval of first and last intersection with the ray. For a
configuration of two convex objects, looking at the possible cases of intervals along
a ray results in nine overall cases, illustrated in Figure 10.2. If any one of cases 5
through 8 occurs for a single pixel, the objects are in collision; otherwise, they are
nonintersecting.
These early accounts rely on reading back the stencil buffer to perform the test.
With modern graphics hardware, buffer readback is neither necessary nor indeed
Search WWH ::




Custom Search