Graphics Reference
In-Depth Information
In this way,
W
dc
W
dc
2
W
dc
2
x
dc
=
x
ndc
×
2
+
=(
x
ndc
+
1
)
×
,
H
d
2
+
H
dc
2
H
dc
2
y
dc
=
y
ndc
×
=(
y
ndc
+
1
)
×
.
2. Resolve visibility/occlusion along the NDC
z
-axis. To determine which ob-
ject is visible on the drawing area, their relative front-to-back ordering must
be resolved. For example, from Figure 14.21, we can see that the teapot oc-
cludes part of the floor. The graphics API uses the Z-buffer hardware to
record the
z
-value for each pixel. When the Z-buffer depth stenciling is
enabled, before a color is assigned to a pixel, the corresponding
z
-value is
compared. A pixel's color will be modified only when the corresponding
primitive's
z
-value is closer to the origin.
The NDC-to-DC transformation described here is the final stage of both the or-
thographic projection (of
Figure 14.8
)
and the perspective projection (of
Fig-
transform. Orthographic projection proportionally scales all vertices in the EC
space into the NDC cube. As discussed in Section 14.6, perspective projection
scales vertices in EC space disproportionately according to their
z
-distance from
the origin. In both cases, the NDC-to-DC transformations are identical.
14.8
Re-Examining Tutorial 13.1
Recall that Tutorial 13.1 is our fist encounter with a 3D program (presented in the
previous chapter). We are now finally ready to examine Step 2 of Listing 13.2
where we programmed the matrix processors. Listing 14.4 shows the details of
Step 2 from Listing 13.2. We see that the matrix processors are set up to transform
vertices from object coordinate (OC) space to the NDC:
Label A
Label B
Label C
C
M
W
C
M
V
C
M
P
O
−→
W
−→
E
−→
NDC
.
Because they are set up to transform coordinates, we will refer to the contents of
the
WORLD
,
VIEW
,and
PROJECTION
matrix processors as
M
o
2
w
(content of the top
of matrix stack),
M
w
2
e
(Equation (14.4) on p. 401), and
M
e
2
n
, respectively. In
this way, with the input vertex in OC space
V
oc
, the output from the
WORLD
matrix
processor
V
wc
is a vertex position in WC space:
=
=
V
oc
M
o
2
w
.
V
wc
V
oc
M
W
Search WWH ::
Custom Search