next up previous contents
Next: 10.1.2 Improved Highlight Shape Up: 10.1 Phong Shading Previous: 10.1 Phong Shading   Contents


10.1.1 Phong Highlights with Texture

One of the problems with the OpenGL lighting model is that specular radiance is computed before textures are applied in the normal pipeline sequence. To achieve more realistic looking results, specular highlights should be computed and added to image after the texture has been applied. This can be accomplished by breaking the shading process into two passes. In the first pass diffuse radiance is computed for each surface and then modulated by the texture colors to be applied to the surface and the result written to the color buffer. In the second pass the specular highlight is computed for each polygon and added to the image in the framebuffer using a blending function which sums 100% of the source fragment and 100% of the destination pixels. For this particular example we will use an infinite light and a local viewer. The steps to produce the image are as follows:

  1. Define the material with appropriate diffuse and ambient reflectance and zero for the specular reflectance coefficients.
  2. Define and enable lights.
  3. Define and enable texture to be combined with diffuse lighting.
  4. Define modulate texture environment.
  5. Draw lit, textured object into the color buffer.
  6. Define new material with appropriate specular and shininess and zero for diffuse and ambient reflectance.
  7. Disable texturing, enable blending, set the blend function to GL_ ONE, GL_ ONE.
  8. Draw the specular-lit, non-textured geometry.
  9. Disable blending.


next up previous contents
Next: 10.1.2 Improved Highlight Shape Up: 10.1 Phong Shading Previous: 10.1 Phong Shading   Contents
2001-01-10