Graphics Reference
In-Depth Information
B
P
A
C
Figure 9.12: The point P of the triangle T = ABC has its color determined by a texture
map. The points A, B, and C have been assigned to points in the checkerboard image, as
shown by the arrows; the point P corresponds to a point in a white square, so its texture
color is white.
object. At a high level, when we are determining the color of a pixel in a rendering
we typically base that computation on information about the underlying object
that appears at that pixel; if it's a triangle of some mesh, we use, for instance, the
orientation of that triangle in determining how brightly lit the point is by whatever
illumination is in the scene. In some cases, the triangle may have been assigned a
single color (i.e., its appearance under illumination by white light), which we also
use, but in others there may be a color associated to each vertex, as in the previous
section, and we can interpolate to get a color at the point of interest. Very often,
however, the vertices of the triangle are associated to locations in a texture map,
which is typically some n
6
4
2
0
k image; it's easy to think of the triangle as having
been stretched and deformed to sit in the image. The color of the point of interest
is then determined by looking at its location in the texture map, as in Figure 9.12,
and finding the color there.
×
0
2468
1
0.5
0
9.6.1 Assignment of Texture Coordinates
2 0.5
When we say that sometimes the vertices of the triangle are associated to locations
in a texture map, it's natural to ask, “How did they get associated?” The answer is
“by the person who created the model.” There are some simple models for which
the association is particularly easy. If we start with an n
2
1
2 1
0
1
k grid of triangles as
shown in Figure 9.13, top, with n = 6 and k = 8, we can associate to each vertex
( i , j ) of this mesh a point in 3-space by setting
×
1
0
θ
= 2
π
j
/
( k
1 )
(9.19)
2
1
2
1
1
2 +
0
0
φ
=
φ
=
π
i
/
( n
1 )
(9.20)
2 1
1
X =cos(
θ
)cos(
φ
)
(9.21)
Figure 9.13: Texture-mapping a
globe.
Y =sin(
φ
)
(9.22)
Z =sin(
θ
)cos(
φ
) ,
(9.23)
θ
φ
that is, letting
denote longitude and latitude, respectively. The approx-
imately spherical shape that results is shown in the middle. We also have a
100
and
200 texture image of an “unprojected” map of the Earth (the vertical
coordinate is proportional to latitude; the horizontal proportional to longitude).
We assign texture coordinates 100 i
×
1 ) to the vertex at posi-
tion ( i , j ) , and the resultant globe is shown rendered with the texture map at the
bottom.
/
( n
1 ) , 200 j
/
( k
 
 
 
Search WWH ::




Custom Search