i
i
i
i
i
i
i
i
838 18. Graphics Hardware
color buffer of 1280 × 1024 pixels with true colors, i.e., 8 bits per color
channel. With 32 bits per color, this would require 1280 × 1024 × 4=5
megabytes (MB). Using double buffering doubles this value to 10 MB. Also,
let us say that the Z-buffer has 24 bits per pixel and a stencil buffer of 8
bits per (these usually are paired to form a 32 bit word). The Z-buffer
and stencil buffer would then need 5 MB of memory. This system would
therefore require 10 + 5 = 15 MB of memory for this fairly minimal set
of buffers. Stereo buffers would double the color buffer size. Note that
under all circumstances, only one Z-buffer and stencil buffer are needed,
since at any moment they are always paired with one color buffer active
for rendering. When using supersampling or multisampling techniques to
improve quality, the amount of buffer memory increases further. Using,
say, four samples per pixel increases most buffers by a factor of four.
18.2 Perspective-Correct Interpolation
The fundamentals of how perspective-correct interpolation is done in a
rasterizer will briefly be described here. This is important, as it forms
the basis of how rasterization is done so that textures look and behave
correctly on primitives. As we have seen, each primitive vertex, v,isper-
spectively projected using any of Equations 4.68-4.70. A projected vertex,
p =(p
x
w, p
y
w, p
z
w, w), is obtained. We use w = p
w
here to simplify the
presentation. After division by w we obtain (p
x
,p
y
,p
z
, 1). Recall that
−1 ≤ p
z
≤ 1 for the OpenGL perspective transform. However, the stored
z-value in the Z-buffer is in [0, 2
b
− 1], where b is the number of bits in
the Z-buffer. This is achieved with a simple translation and scale of p
z
.
Also, each vertex may have a set of other parameters associated with it,
e.g., texture coordinates (u, v), fog, and color, c.
The screen position (p
x
,p
y
,p
z
) can be correctly interpolated linearly
over the triangle, with no need for adjustment. In practice, this is often
done by computing delta slopes:
Δz
Δx
and
Δz
Δy
. These slopes represent how
much the p
z
value differs between two adjacent pixels in the x-andy-
directions, respectively. Only a simple addition is needed to update the
p
z
value when moving from one pixel to its neighbor. However, it is im-
portant to realize that the colors and especially texture coordinates cannot
normally be linearly interpolated. The result is that improper foreshort-
ening due to the perspective effect will be achieved. See Figure 18.6 for
a comparison. To solve this, Heckbert and Moreton [521] and Blinn [103]
show that 1/w and (u/w, v/w) can be linearly interpolated. Then the in-
terpolated texture coordinates are divided by the interpolated 1/w to get
the correct texture location. That is, (u/w, v/w)/(1/w)=(u, v). This type
of interpolation is called hyperbolic interpolation, because a graph of the