i
i
i
i
i
i
i
i
154 6. Texturing
a space is as points on a unit sphere. The most common type of texture
using a directional parameterization is the cube map (see Section 6.2.4).
It is also worth noting that one-dimensional texture images and func-
tions have their uses. For example, these include contour lines [475, 969]
and coloration determined by altitude (e.g., the lowlands are green; the
mountain peaks are white). Lines can also be textured; one use of this is
to render rain as a set of long lines textured with a semitransparent im-
age. Such textures are also useful for simply converting from one value to
another.
Since multiple textures can be applied to a surface, multiple sets of tex-
ture coordinates may need to be defined. However the coordinate values
are applied, the idea is the same: These parameter values are interpolated
across the surface and used to retrieve texture values. Before being inter-
polated, however, these parameter values are transformed by corresponder
functions.
6.1.2 The Corresponder Function
Corresponder functions convert parameter-space coordinates to texture-
space locations. They provide flexibility in applying textures to surfaces.
One example of a corresponder function is to use the API to select a por-
tion of an existing texture for display; only this subimage will be used in
subsequent operations.
Another type of corresponder is a matrix transformation, which can be
applied in the vertex or pixel shader.
3
This enables to translating, rotating,
scaling, shearing, or projecting the texture on the surface.
4
Another class of corresponder functions controls the way an image is
applied. We know that an image will appear on the surface where (u, v)are
in the [0, 1) range. But what happens outside of this range? Corresponder
functions determine the behavior. In OpenGL, this type of corresponder
function is called the “wrapping mode”; in DirectX, it is called the “texture
addressing mode.” Common corresponder functions of this type are:
• wrap (DirectX), repeat (OpenGL), or tile—The image repeats itself
across the surface; algorithmically, the integer part of the parameter
value is dropped. This function is useful for having an image of a
material repeatedly cover a surface, and is often the default.
3
This is also possible on fixed-function hardware; the OpenGL fixed-function pipeline
supports the use of a 4 × 4matrix.
4
As discussed in Section 4.1.5, the order of transforms matters. Surprisingly, the
order of transforms for textures must be the reverse of the order one would expect. This
is because texture transforms actually affect the space that determines where the image
is seen. The image itself is not an object being transformed; the space defining the
image’s location is being changed.