Texture mapping seems like such a straight forward concept and, really, it is. However, there's an underlying depth to textures that most people don't fully understand that prevents some from using them to the best advantage. The obvious way to think of texture maps is that they're like stickers. You simply paste them on things and that's that. Actually, you can go a long way with that concept. You may never need to know any more about textures than that. However, there is quite a bit more to know, and once you understand a few concepts, textures start getting a lot more useful and a lot more fun.
Let's talk about texture coordinates. Texture space is measured with the coordinates u, v, and w. U represents side to side, v represents up and down, and w represents depth (giving us 3D for procedural textures). In VRML we only use the u and v coordinates (2D) so you don't need to worry about w. If you look at a texture map, the origin (u=0,v=0) is always the lower left corner, upper left is 1,0 - lower right is 0,1 - and upper right is 1,1; This holds true regardless of the size or shape of the texture.
The big difference between texture coordinates and geometry coordinates is what they measure. Geometry coordinates (x, y, and z) are a reference system for placing geometry in three dimensional space. For example, an object exists at one set of coordinates. If you move it, it exists at a new set. If you scale it, rotate it, whatever, it gets still another. Texture coordinates, however, only measure texture repetitions. That's why the upper right corner is 1,1. It will always be 1,1 no matter how you scale or stretch the texture. The space between 0,0 and 1,1 is one repetition of the texture. If we use more than one repetition, we start tiling the texture. Each tile adds 1 to the u and/or the v coordinates (or subtracts 1 if we want to tile it in a negative direction). So a set of texture coordinates from 0,0 to 2,2 would be a grid of four tiles of our texture. As you can see, the sticker is really more like a sheet of postage stamps.
Texture space is wonderfully, perfectly, mathematically flat (or cubic if you consider the w coordinate). However the surfaces that textures are placed on are often not flat at all. So we need yet another coordinate system to define surface space. Surface space is defined with the coordinates s and t, s being the horizontal component and t the vertical. S, t coordinates are exactly equivalent to u, v coordinates (and you probably won't get into trouble if you use them interchangeably) but they represent a totally different concept. Since the surface being mapped may be very irregular, s, t coordinates let us find a particular spot on the texture map (u, v coordinates) regardless of any stretching or distortion that may have taken place in order to get the 2D texture onto the 3D surface. In other words, (stay with me here) the u, v coordinates of the 2D image are referenced by the s, t coordinates on the surface that relate to the x, y, and z coordinates of the 3D geometry. See, that wasn't so hard, was it?
Since surfaces are usually made up of polygons, it's handy to reference the texture coordinates in relation to the vertices of the polygons in the object you're texture mapping. Vertices provide a nice "hook" in x, y, and z space to reference the s, t coordinates of the map that's been placed on the surface of the object. This is what that long list of numbers is in a TextureCoordinate2 node (in VRML 1.0) or TextureCoordinate node (in VRML 2.0) - the s, t coordinates at the vertices of the polygons. (These are also sometimes referred to as "texture vertices.")
If you'd like to learn more about texture coordinates and how textures are applied check out Computer Graphics: Principles and Practice, 2nd Edition, by Foley... et al, pp 741-744.
This article is taken from Texture Mapping in VRML by Cindy Reed. Please direct any comments, corrections, or suggestions to: firstname.lastname@example.org
#VRML V2.0 utf8 | WorldInfo | ViewPoint | Shape
© 1996 Aereal, Inc.