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

 

tex2html_wrap10927

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

The vector from the eye point to the vertex is denoted as tex2html_wrap_inline10915, normalized to tex2html_wrap_inline10917. Since the computation is performed in eye coordinates, the eye is located at the origin and tex2html_wrap_inline10915 is equal to the location of the vertex. The current normal tex2html_wrap_inline10726 is transformed to eye coordinates, becoming tex2html_wrap_inline10923. The reflected vector tex2html_wrap_inline10925 can be computed as:
equation2875
We define:
equation2882
Then the texture coordinates are calculated as:
eqnarray2885
This computation happens internally to OpenGL in the texture coordinate generation step.

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