Graphics Reference
In-Depth Information
where p r = ( x r , y r ) gives the coordinates of the pixel in pixel space and p a = ( x a , y a )
and p b = ( x b , y b ) give the screen coordinates of the endpoints in pixel space of
the line segment containing the pixel.
Simple linear interpolation like this is readily supported by graphics
hardware and is used to interpolate simple values such as depth and smooth-
shading color. But it has some problems if we use simple linear interpolation
in model space when the real graphical meaning of those values is determined
in clip space. For interpolating these kinds of values, such as texture coordi-
nates, we need to do the actual interpolation in clip space. That is more inter-
esting. For these values, instead of linear interpolation, OpenGL uses a modi-
fied interpolation function (using the same parameter t as above) given by
(
)
1
1
tfwt fw
t wt w
+
a
b
b
a
,
(
)
α
+
α
a
b
b
a
where α = 1 unless you are interpolating textures and the texture coordinates
( s , t , r , q ) have q ≠ 1; in that case α a = q a and α b = q b . Further, w a and w b are the
fourth coordinate of the endpoints a and b in homogeneous clip space. Again, if
t = 0, we simply get the value f a and if t = 1, we get f b (or their homogenized value
if f is a texture coordinate). We may call this a perspec-
tive interpolation , because it is really only different from
linear interpolation when clip space is different from
eye space, which happens with a perspective projection.
This interpolation can be quite non-linear if the original
endpoints a and b have different z -values, because the
values of w a and w b are generally the reciprocals of those
z -values. Figure 1.9 shows how a value (in this case one
of the coordinate values) is interpolated by this process
between two endpoints; notice that this is not linear.
Although we think of depth in terms of the z-val-
ues in clip space, depth computations are not done with
these values. That is, the depth buffer is not a traditional
z-buffer. The depth value for a pixel in screen space is
represented in fixed-point form (effectively as an inte-
ger) with at least as many bits as are in the depth buffer,
and the depth buffer stores these values, truncated if nec-
essary, for depth comparisons. Thus, the depth value is
aliased, and to minimize aliasing problems, you want to
define your near and far clipping planes so the distance
between them is as small as possible. The near clipping
Figure 1.9. Interpolating the x -coordi-
nates of two points in 2D eye space. The
points are (-3, -1, 3, 1) and (3, -1, 5, 1) in
3D eye space.
Search WWH ::




Custom Search