SPHEREMAP mode

The SPHERE_MAP mode is very different from the OBJECT_LINEAR or EYE_LINEAR modes in that it always generates 2D (s,t) texture coordinates irrespective of any mapping planes passed to the TexCoordGeneration constructor.

The SPHERE_MAP mode calculates texture coordinates based on the vector passing from the origin (in world coordinates) to a vertex. It creates a mapping that essentially paints an environment map onto the face of an object. Imagine that the object was a reflective sphere positioned in the center of a room. If the SPHERE_MAP texture coordinate generation mode was used, the sphere would appear to reflex the items within the room. By precomputing a spherical texture map using a ray-tracing program and using the SPHERE_MAP texture mode, a photorealistic reflective object can be created.

Please refer to the OpenGL 1.1 NOTE Specification for the mathematical details of how the texture coordinates are calculated from the vector passing from the origin to each vertex. Because the SPHERE_MAP mode always generates both s and t coordinates, we have to create a texture image to achieve the effect in figure 14.10. This texture image is shown in figure 14.11. However, because both the TexCoordTest example in EYE_LINEAR and OBJECT_LINEAR modes only use the t = 0 row of the image, their results are unchanged.

Figure 14.10 Using sphere_map texture coordinate generation. Instead of the texture image being used to denote contour lines on the landscape, the landscape can now be considered to be a reflective surface within a spherical room that has the texture image applied as wallpaper to its inner walls

Figure 14.11 Texture image used for sphere_map texture coordinate generation

0 0

Post a comment

  • Receive news updates via email from this site