Graphics Reference
In-Depth Information
In our context, an image (or an image file) is simply a formatted file containing
a 2D array of colors. When we view this file with an image viewer application,
an image will be displayed. The color of each pixel on the displayed image will
correspond to an element in the 2D array of the formatted file. Some popular file
formats for storing images include: jpg, tiff, gif, png, and so on. In this way, “an
image” or a “file texture” is simply a file that contains a digital photograph, a cre-
ative art drawing, or the results of a scanner operation. As long as a file contains a
2D array of colors and is formatted according to some image file format, we can
useitasafiletexture.
File texture mapping treats an image file as a texture and maps this texture
onto a primitive. In this chapter, we are interested in understanding the basic
concepts of file texture mapping such that we can incorporate textures into our
applications.
12.3.2
Texture Coordinates
Two coordinate systems are defined on the texture image and on the primitive to
enable the mapping.
1. The st coordinate system on file textures. Graphics hardware implicitly
defines a normalized coordinate system over a file texture.
st=(0,0)
st=(1,0)
s
2. The uv coordinate system on primitives. Our programs must explicitly
define texture coordinate positions for each vertex of our primitive.
t
Based on these two coordinate systems, correspondence between pixel and texel
positions is established, and the color identified by the texel is used in computing
the final color of the pixel.
s
The Implicit st Coordinate System.
t
st=(0,1)
st=(1,1)
This coordinate system is implicitly defined over any given file texture. We em-
phasize “implicitly defined” because the st coordinate is defined over an image
as soon as the texture file is loaded into the graphics hardware. As illustrated in
Figure 12.13, here are some characteristics of the st system.
Figure 12.13.
The st co-
ordinate system.
Origin. The upper-left corner of the image.
Axis directions. s -axis increases rightward, and t -axis increases down-
ward.
Normalized. Va l u e s f o r st are always in the range 0 to 1
.
0.
Search WWH ::




Custom Search