next up previous contents
Next: 10.1.3 Spotlight Effects using Up: 10.1 Phong Shading Previous: 10.1.1 Phong Highlights with

10.1.2 Improved Highlight Shape

This implements the basic algorithm, but the Gouraud shaded specular highlight still leaves something to be desired. We can improve on the specular highlight by using environment mapping to generate a higher quality highlight. We generate a sphere map consisting only of a Phong highlight [78] and then use the GL_SPHERE_MAP texture coordinate generation mode to generate texture coordinates which index this map. For each polygon in the object, the reflection vector is computed at each vertex. Since the coordinates of the vector are interpolated across the polygon and used to lookup the highlight, a much more accurate sampling of the highlight is achieved compared to interpolation of the highlight value itself. The sphere map image for the texture map of the highlight can be computed by rendering a highly tessellated sphere lit with only a specular highlight using the regular OpenGL pipeline. Since the direction of the light relative to the view direction is effectively encoded in the texture map, the texture map needs to be recomputed whenever the light or viewer position is changed. Sphere mapping assumes that the view direction is constant (infinite viewer) and the environment (light) direction is infinitely far away, so the highlight does not need to be changed when the object moves.

The nine step method outlined above needs minor modifications to incorporate the new lighting method:

1.
Disable lighting.
2.
Load the sphere map texture, enable the sphere map texgen function.
3.
Enable blending, set the blend function to GL_ONE, GL_ONE.
4.
Draw the unlit, textured geometry with vertex colors set to 1.0.
5.
Disable texgen, disable blending.

With a little work the technique can be extended to handle multiple light sources. OpenGL 1.2 includes new functionality which enables the per-vertex lighting computation to compute a specular contribution separate from the ambient, diffuse, and emissive contributions and adds this specular contribution in after the application of the texture environment. Since this contribution is calculated per-vertex and interpolated it solves the specular-after-texture problem, but it does provide any additional improvement in the shape or quality of the highlight, so the above technique remains useful for improving the highlight quality.

 


next up previous contents
Next: 10.1.3 Spotlight Effects using Up: 10.1 Phong Shading Previous: 10.1.1 Phong Highlights with
David Blythe
1999-08-06