Graphics Reference
In-Depth Information
In this case, the way we created the mesh made it natural to create the tex-
ture coordinates at the same time. There is one troubling aspect of this approach,
though: The texture coordinates depend on the number of pixels in the image that
we use as our world map. If we created this shape and decided that the result
looked bad, we might want to use a higher-resolution image, but that would entail
changing the texture coordinates as well. Because of this, texture coordinates are
usually specified as numbers between zero and one, representing a fraction of the
way up 2 or across the image, so texture coordinates ( 0. 75, 0. 5 ) correspond to a
point three-quarters of the way up the texture image (regardless of size) and mid-
way across, left to right.
It's commonplace to name these texture coordinates u and v so that a typical
vertex now has five attributes: x , y , z , u , and v . Sometimes texture coordinates are
referred to as uv -coordinates.
9.6.2 Details of Texture Mapping
If we have a mesh with texture coordinates assigned at each vertex, how do we
determine the texture coordinates at some location within a triangle? We use the
techniques of this chapter, one coordinate at a time. For instance, we have a
u -coordinate at every vertex; such an assignment of a real value at every vertex
uniquely defines a piecewise linear function at every point of the mesh: If P is a
point of the triangle ABC , and the u -coordinates of A , B , and C are u A , u B , and u C ,
we can determine a u -coordinate for P using barycentric coordinates. We write
P in the form
P =
α
A +
β
B +
γ
B
(9.24)
and then define
u ( P )=
α
u A +
β
u B +
γ
u C .
(9.25)
We can do the same thing for v , and this uniquely determines the uv -coordinates
for P .
If the triangle ABC happens to cover many pixels, we'll do this computation—
find the barycentric coordinates and use them to combine the texture coordinates
from the vertices—many times. Fortunately, the regularity of pixel spacing makes
this repeated computation particularly easy to do in hardware, as described in
Chapter 38.
9.6.3 Texture-Mapping Problems
If a triangle has texture coordinates that make it cover a large area of the texture
image, but the triangle itself, when rendered, occupies a relatively small portion
of the final image, then each pixel in the final image (thought of as a little square)
corresponds to many pixels in the texture image. Our approach finds a single point
in the texture image for each final image pixel, but perhaps it seems that the right
thing to do would be to blend together many texture image pixels to get a com-
bined result. If we do not do this, we get an effect called texture aliasing, which
we'll discuss further in Chapters 17, 20 and 38. If we do blend together texture
2. Or down, if the image pixels are indexed from top to bottom, as often happens.
 
 
 
Search WWH ::




Custom Search