next up previous contents
Next: Generating a Sphere Map Up: 9.3.2 Sphere Mapping Previous: 9.3.2 Sphere Mapping

Using a Sphere Map

 

table2039

OpenGL provides a mechanism to generate s and t texture coordinates at vertices based on the current normal and the direction to the eyepoint. The generated coordinates are then used to index a sphere map image which has been bound as a texture.

We denote the vector from the eye point to the vertex as u, normalized to u'. Since the computation is performed in eye coordinates, the eye is located at the origin and u is equal to the location of the vertex. The current normal n is transformed to eye coordinates, becoming n'. The reflected vector r can be computed as:
equation1762
We define:
equation1764
Then the texture coordinates are calculated as:
eqnarray1767
This computation happens internally to OpenGL in the texture coordinate generation step.

To use sphere mapping in OpenGL, the following steps are performed:



David Blythe
Thu Jul 17 21:24:28 PDT 1997