next up previous contents
Next: 6.4 Texture Borders and Up: 6. Texture Mapping Previous: 6.2.2 Multitexture Texture Environments

6.3 Merging Textures with Specular Highlights

Unfortunately, when a lit polygon includes a specular highlight, the resulting modulated texture will not look correct since the specular highlight simply changes the brightness of the texture at that point rather than the desired effect of adding in some specular illumination. Some vendors have addressed this problem with extensions to perform specular lighting after texturing. The EXT_separate_specular_color extension permits the color result from the per-vertex specular lighting computation to be separately interpolated during rasterization and then added to the fragment's color after the texture environment. This new step in the OpenGL pipeline is called the color sum. OpenGL 1.2 integrates the separate specular color functionality into the OpenGL core standard. Enabling the separate specular color functionality in OpenGL 1.2 is easy:

OpenGL's default behavior is restored by:

One limitation of the separate specular color functionality is that the secondary color (as it is called) added in during the color sum stage can only be supplied through OpenGL's per-vertex specular lighting computation. When lighting is disabled, there is no way to control the secondary color. The EXT_secondary_color extension permits the secondary color to be pass directly into OpenGL via the command glSecondaryColor3fEXT(). This can be very useful is you wish to perform your own per-vertex lighting model that supplies independent specular highlights. Here is an example assuming the extension is supported:

 glEnable(GL_COLOR_SUM_EXT);       /* enable color sum
                                      with explicit secondary color  */
 glColor4f(0, 0.3, 0.5);           /* explicit primary color (RGBA)  */
 glSecondaryColor3fEXT(1, 1, 0.8); /* explicit secondary color (RGB) */
Neither of these techniques address a problem fundamental to per-vertex computation of specular highlights though. Because specular highlights change rapidly over a shiny surface, when an object is not sufficiently tessellated, the specular highlight tend to ``wobble'' as the object moves or rotates. This is due to the specular highlight sometimes being correctly sampled when a vertex is close to the highlight, but poorly sampled if a vertex is not close to the highlight. Other techniques that can be used to address this problem are discussed in Section 10.1.1.

next up previous contents
Next: 6.4 Texture Borders and Up: 6. Texture Mapping Previous: 6.2.2 Multitexture Texture Environments
David Blythe