Graphics Reference
In-Depth Information
36.5 Frustum Culling and Clipping
Assume that we rely on an exact method like a depth buffer or Newell et al.'s
depth-sort algorithm for correct visibility under rasterization. To avoid writing
to illegal or incorrect memory addresses, assume that we perform 2D scissoring
to the viewport. This just means that the rasterizer may generate ( x , y ) locations
that are outside the viewport, but we only allow it to write to memory at locations
inside the viewport. We can also scissor in depth: No sample may be written whose
depth indicates that it is behind the camera or past the far plane.
Recall that Chapter 13 showed that a rectangular viewport with near and far
planes parallel to the image plane defines a volume of 3D space called the view
frustum. This is a pyramid with a rectangular base and the top cut off. Clipping
to the sides of the view frustum in 3D corresponds to clipping the projection of
primitives to the viewport, and produces equivalent results to simply scissoring
in 2D.
Scissoring alone ensures correctness, but it may lead to poor efficiency. For
example, most primitives that are rasterized may fail the scissor test. There are
three common approaches to increasing efficiency in this case that are related to
the view frustum.
Frustum culling: Eliminate polygons that are entirely outside the frustum,
for efficiency.
Near-plane clipping: Clip polygons against the near plane to enable sim-
pler rasterization algorithms and avoid spending work on samples that fail
depth scissoring.
Whole-frustum clipping: Clip polygons to the side and far planes, for
efficiency.
In general, it is a good strategy to use scissoring and clipping to complement
each other. Use each only for the case where it has high efficiency and low imple-
mentation complexity. For example, use a coarse culling based on the view frus-
tum followed by clipping to the near plane and scissoring in 2D. For primitives
whose projections are small compared to the viewport, this leads to the scissor
test usually passing, which means that most parts of most rasterized primitives for
which significant computation is performed are usually on the screen.
36.5.1 Frustum Culling
Eliminating polygons outside the view frustum is simple. One 3D algorithm for
this tests each vertex of a polygon against each plane bounding the view frustum.
Assume that the planes are oriented so that the view frustum is the intersection of
the six positive half-spaces. If there exists some plane for which all vertices of a
polygon are in the negative half-space, then that polygon must lie entirely outside
the view frustum and can be culled. For small polygons, it may not be efficient to
perform this test on each polygon. For example, if a polygon affects at most one
sample, then a 3D bounding box test on a single point yields the same result. So
frustum culling may be performed on a bounding box hierarchy.
A drawback of the 3D frustum culling algorithm just described is that it may
be too conservative. Polygons that are outside the view frustum but near a corner
or edge may intersect multiple planes.
 
 
 
Search WWH ::




Custom Search