Graphics Reference
In-Depth Information
3D world
coordinates
for geometry
Coordinates in
standard view
volume
Coordinates on ilm
plane in standard
view volume
2D device
coordinates
Transform
to viewport
in 2D device
coordinates
Transform
to standard
view volume
Clip against
standard
view volume
Project to
film plane
Figure 13.15: Transformation to standard view volume makes clipping simpler.
view volume and partly outside may be truncated to a quadrilateral (and then typ-
ically subdivided into two new triangles). Alternatively, a system may determine
that the truncation and retriangulation is more expensive than handling the small
amount of work of generating pixel data that will never be shown; this depends on
the architecture of the hardware doing the rasterization. The clipping operation is
discussed in more detail in Chapters 15 and 36.
We'll show how to implement this abstract rendering process in the con-
text of camera transformations. Instead of clipping world coordinates against the
camera's view volume, we'll transform the world coordinates to a standard view
volume, where clipping is far simpler. In the standard view volume, we end up
clipping against coordinate planes like
z
=
3D world
coordinates
for geometry
Transform to
standard
perspective
view volume
−
1, or against simple planes like
x
=
z
or
y
=
z
. The projection to the film plane in the second step of the
sequence is no longer a generic projection onto a plane in 3-space, but a projec-
tion onto a standard plane in the standard parallel view volume, which amounts to
simply forgetting the
z
-coordinate. The revised sequence of operations is shown
in Figure 13.15.
The dark gray section (the left half) of the sequence shown in Figure 13.15
can be further expanded for the perspective camera, as shown in Figure 13.16. In
this case, we multiply by
M
pp
to transform from the standard perspective view
volume to the standard parallel view volume, but before homogenizing, we clip
out objects with
z
−
Coordinates
in standard
view volume
Transform to
standard
parallel
volume,
unhomogenized
General 4D
coordinates
<
0. Why? Because an object with
z
<
0
and w
<
0, after
Clip to remove
z
< 0 points
homogeneous division, will transform to one with
z
0 and
w
=
1. In practice,
this means that objects behind the camera can reappear in front of it, which is not
what we want.
>
Following this first clipping phase, we can homogenize and clip against
x
and
y
and the far plane in
z
, all of which are simple because they involve clipping against
planes parallel to coordinate planes.
To interpret the entire sequence of operations mathematically, we start with
our world coordinates for triangle vertices and then do the following.
Homogenize
3D
coordinates
with
w
5
1
1. Multiply by
M
pp
M
per
, transforming points into the standard perspective
view volume with
M
per
, and thence toward the standard parallel view vol-
ume (
M
pp
), stopping just short of homogenization.
2. Clip to remove points with
z
Clip in
x
and
y
, and
remove
z
< 21
points
0. This, and step 4, actually requires knowl-
edge of
triangles
rather than just the vertex data.
3. Apply the homogenizing transformation
(
x
,
y
,
z
,
w
)
<
y
w
,
(
w
,
z
→
w
,1
)
,at
Figure
13.16:
Clipping
in
the
which point we can drop the
w
-coordinate.
perspective case.