Game Engine Architecture

(Ben Green) #1
419

environment maps (which contain a picture of the surrounding environment
for rendering refl ections), and many others. See Section 10.3.1 for a discussion
of how various types of textures can be used for image-based lighting and
other eff ects.
We can actually use texture maps to store any information that we happen
to need in our lighting calculations. For example, a one-dimensional texture
could be used to store sampled values of a complex math function, a color-to-
color mapping table, or any other kind of look-up table (LUT).


Texture Coordinates


Let’s consider how to project a two-dimensional texture onto a mesh. To do
this, we defi ne a two-dimensional coordinate system known as texture space.
A texture coordinate is usually represented by a normalized pair of numbers
denoted (u, v). These coordinates always range from (0, 0) at the bott om left
corner of the texture to (1, 1) at the top right. Using normalized coordinates
like this allows the same coordinate system to be used regardless of the di-
mensions of the texture.
To map a triangle onto a 2D texture, we simply specify a pair of texture
coordinates (ui, vi) at each vertex i. This eff ectively maps the triangle onto the
image plane in texture space. An example of texture mapping is depicted in
Figure 10.15.


Figure 10.15. An example of texture mapping. The triangles are shown both in three-dimen-
sional space and in texture space.


Texture Addressing Modes


Texture coordinates are permitt ed to extend beyond the [0, 1] range. The
graphics hardware can handle out-of-range texture coordinates in any one of


10.1. Foundations of Depth-Buffered Triangle Rasterization

Free download pdf