Graphics Reference
In-Depth Information
36.5.3 Clipping to the Whole Frustum
Having clipped against the near plane, we are guaranteed that for every vertex
in the polygon z
<
0. This means that we can project the polygon into homo-
geneous clip space, mapping the frustum to a cube through perspective projection
as described in Chapter 13.
We could continue with Sutherland-Hodgman clipping for the other frustum
planes in 3D before projection. However, the side planes are not orthogonal to
an axis the way that the near plane is, so clipping to those planes takes more
operations per vertex. In comparison, after perspective projection every frustum
plane is orthogonal to some axis, so clipping is just as efficient for a side plane as
it was for the near plane. That is, clipping is again a 2D operation. Clipping to the
far plane can be performed either before or after projection.
When clipping in Cartesian 3D space against the near plane, we were able to
linearly interpolate per-vertex attributes such as texture coordinates. In homoge-
neous clip space, those attributes do not vary linearly along an edge, so we cannot
directly linearly interpolate. However, the relationship is nearly as simple.
In practice, we don't need all of those operations for each edge clipping oper-
ation. Instead, we can project every attribute by u =
z when projecting posi-
tion. Then we can perform all clipping on the u attributes as if they were linear
and all operations were 2D. Recall that rasterization needs to interpolate attributes
in a perspective-correct fashion, so it operates on the u attributes along a scan
line anyway (see The Depth Buffer). Only at the per-sample “shading” step do we
return to the original attribute space, by computing u =
u
/
u z with the hyperbol-
ically interpolated z -value. Thus, in practice, the clipping (and rasterization) cost
for 3D attributes is the same as for 2D attributes, and all of the 2D optimization
techniques such as finite differences can be applied to the u -values.
36.6 Backface Culling
The back of an opaque, solid object is necessarily hidden from direct line of sight
from an observer. The object itself occludes the view rays. Culling primitives that
lie on the backs of objects can therefore conservatively eliminate about half of
the scene geometry. As pointed out previously, backface culling is a good opti-
mization when computing the visibility function, but not for the entire render-
ing pipeline. When we consider the entire rendering pipeline, the image may be
affected by points not directly visible to the camera, such as objects seen by their
reflections in mirrors and shadows cast by objects outside the field of view. So,
while backface culling is one of the first tools that we reach for when optimiz-
ing visibility, it is important to apply it at the correct level. One can occasionally
glimpse errors arising from programs culling at the wrong stage, such as shadows
disappearing when their caster is not in view.
Although backface culling could be applied to parametric curved surfaces, it
is typically performed on polygons. That is because a test at a single point on the
polygon indicates whether the entire polygon lies on the front or back of an object,
so it is very efficient to test polygons. A curve may require tests at multiple points
or an analytic test over the entire surface to make the same determination.
We intuitively recognize the back of an object—it is what we can't see!—but
how can we distinguish it geometrically? Consider a closed polygonal mesh with
no self-intersections, and an observer at point Q that lies outside the polyhedron
 
 
 
Search WWH ::




Custom Search