Graphics Reference
In-Depth Information
Any convex polygon can be triangulated, or broken
up into triangles, by choosing any vertex and constructing
a triangle fan by processing the vertices in order, starting
with that vertex. (A non-convex polygon does not have that
property, even though you might be able to find a way to
make up the polygon from triangles, as is the case with the
middle example of Figure 1.6.) This concept also extends
to other geometry constructors, such as quad strips; an
OpenGL quad strip is defined in such a way that it can
as easily be viewed as a triangle strip. Since OpenGL only
handles convex polygons, we can assume polygons are
convex, and so we can simply use triangles as our model
for polygon processing.
A key concept in rendering is interpolation . Given a
set of vertices in screen coordinates and a polygon defined
by their grouping, interpolation is needed to determine the
edges that bound the polygon, and interpolation is again
needed to fill the interior of the polygon. The interpolation
not only creates locations to be filled, but also interpolates
all the accompanying properties, such as depth, color, and
texture coordinates. Interpolation is supported by graph-
ics hardware; in the fixed-function rendering pipeline, this
handles simple interpolation (needed for depth or smooth
shading) and perspective interpolation (needed for accu-
rate coordinates, especially texture coordinates).
The interpolation for smooth-shaded color or for
depth is linear interpolation of these values at the vertices or the endpoints of
an edge. This interpolation first interpolates the vertex colors along the edges
of the object and then interpolates the edge colors across the interior of the
object. This interpolation may not be exactly as you imagined it would be.
Figure 1.7 (top) shows a simple quad having one blue, one green, and two red
vertices, with fixed-function color interpolation across the interior. You see
that the shading looks as though there were two triangles that were interpo-
lated separately, one including the top right vertex and the other including the
botom left vertex, as shown in the botom image in the igure. 1 This is obvi-
ously a weakness in simple interpolation shading that we would like to be able
to deal with, as we will discuss in Chapter 15.
Figure 1.7. Linear color interpola-
tion across a polygon.
1. You can tell that something is not right in the way this quad is being rendered because the upper-left
to lower-right diagonal has just green-blue colors on it. There is no evidence of red on the diagonal
despite there being two vertices colored red.
Search WWH ::




Custom Search