Tuesday 19 July 2011

Texture Mapping

Texture mapping was another objective that seemed complicated at first. The idea is to map the point on an object in 3-space to a 2-dimensional image and colour the point with the corresponding pixel in the image. I started with spheres, and again, it took a long time to actually get the math right.
After spheres, I did planes, which is the easiest primitive to map onto.  Simply repeat the texture over and over again from a starting point out.
Other primitives where giving me trouble. Cones in particular were tricky. Then I discovered sphere-mapping. This is a method of texture mapping analogous to shrink wrapping. Simply project the texture onto a sphere, and then map the sphere onto any object using the radial distance from the center. The same method works for any bounded primitive (i.e. not planes).
Here is an example of texture mapping. A world map is texture-mapped on a cylinder and a box. The cone has the texture of a pine tree, and the sphere has a moon texture. The plane is textured with grass.

No comments:

Post a Comment