Texture Mapping

Texture mapping is the process of mapping a scanned or hand-drawn image (called the texture map or simply the texture) onto a polygon. Often used in 3D games, texture mapping produces vivid images that are much more realistic than solid color or shaded polygons. Two popular texture mapping methods are linear texture mapping (also called affine texture mapping) and perspective texture mapping. Fastgraph supports both linear and perspective texture mapping for convex polygons in 256-color and direct color virtual buffers.

The basic idea of texture mapping is to take a source polygon defined within a texture map and project it onto a destination polygon. The texture map is most often defined in rectangular (u,v) coordinates called texels. The vertices of the source polygon are also defined in terms of these same (u,v) coordinates, but we must make sure that the source polygon vertices do not extend beyond the width or height of the texture map. The destination polygon has the same number of vertices as the source polygon and is defined in (x,y) coordinates. We obtain the destination polygon vertices by applying transformations f and g to the source polygon vertices so x=f(u) and y=g(v). The transformations f and g are usually the same 3D projection, meaning each (x,y) vertex in the destination polygon is the projected (u,v) vertex from the source polygon. The projected (x,y) pixels drawn in the destination polygon are taken from the corresponding original (u,v) pixels in the source polygon.

For example, suppose our destination polygon appears on the left in the illustration below. If we apply the 128x128 texture map shown in the middle to the destination polygon, we'll produce the linear texture-mapped polygon shown on the right:

In this example, our source polygon is a 128x128 square (the same size as the texture map). The source polygon doesn't have to be square, or even rectangular, as long as it has the same number of vertices as the unclipped destination polygon and does not extend beyond the texture map limits.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.