Techniques for Controlling Texture Mapping
By Andrea L. Ames
Last month I discussed basic texture mapping in VRML. I also gave you a preview of a few techniques for maximizing the use of textures and creating 3D worlds that perform better on viewers' platforms.
The basic texture-mapping process I specified last month was:
- Build a VRML shape.
- Specify a texture as part of the shape's appearance.
- Specify the geometry onto which you want the texture mapped.
This month, I will explore in detail both step 2 and the texture-controlling techniques, or "texture transformations," at which I hinted last month. Step 2 can in turn be broken down into four parts, somewhat analogous to cutting cookies from a sheet of dough:
- Specify a texture image using the appropriate VRML node (ImageTexture, PixelTexture, or MovieTexture).
- Specify 2D texture coordinates to describe the shape of a "cookie cutter."
- "Cut" a piece of the texture image using the cookie cutter.
- Apply the texture to fit one face of a shape by mapping each corner of the texture with a corresponding face coordinate,transforming the texture as necessary to create the desired effect.
You can transform the texture just as you would geometry, by scaling, rotating, or translating it. You can also wrap, clamp, or repeat the texture, which you cannot do with geometry. You apply, or bind, the texture to one face by mapping texture coordinates to shape coordinates, similar to other forms of VRML binding (like binding colors to point sets, line sets, and face sets).