134 CHAPTER 5: Textures^
The Language of Texturing
Say you wanted to create an airstrip in a game you’re working on. How would you do
that? Simple, take a couple of black triangles and stretch them really long. Bang! You’ve
got your landing strip! Not so fast there, sport. What about the lines painted down the
center of the strip? How about a bunch of small white faces? That could work. But don’t
forget those yellow chevrons at the very end. Well, add a bunch of additional faces and
color them yellow. And don’t forget about the numbers. How about the curved lines
leading to the tarmac? Pretty soon you might be up to hundreds of triangles, but that
still wouldn’t help with the oil spots, repairs, skid marks, and roadkill. Now it starts
getting complicated. Getting all of the fine detail could require thousands if not tens of
thousands of faces. Meanwhile, your buddy, Arthur, is also creating a strip. You are
comparing notes, telling him about polygon counts, and you haven’t even gotten to the
roadkill yet. Arthur says all he needed was a couple of triangles and one image. You see,
he used texture maps, and using texture maps can create a highly detailed surface such
as an airstrip, brick walls, armor, clouds, creaky weathered wooden doors, a cratered
terrain on a distant planet, or the rusting exterior of a ’56 Buick.
In the early days of computer graphics, texturing (or texture mapping) used up two of the
most precious resources: CPU cycles and memory. Texture mapping was used
sparingly, and all sorts of little tricks were done to save on both resources. With memory
now virtually free (compared to 20 years ago) and with modern chips having seemingly
limitless speed, using textures is no longer a decision one should ever have to stay up all
night and struggle with.
All About Textures (Mostly)
Textures come in two broad types: procedural and image. Procedural textures are
generated on the fly based on some algorithm. There are ‘‘equations’’ for wood, marble,
asphalt, stone, and so on. Nearly any kind of material can be reduced to an algorithm
and hence drawn onto an object, as shown in Figure 5-1.
Figure 5-1. A golden chalice (left). By using procedural texture mapping (right), the chalice can be made up of
gold ore instead, while the cone uses a marble map.