Sign in to follow this  

Specular Highlights on Textured Objects

Recommended Posts

I'm having some trouble with specular highlights on textured objects: They don't exist! Apparently, what happens is, the lighting calculations are made, and then clamped from 0 to 1 for each of (r,g,b) and that gets multiplied by the texture color. So the brightest specular highlight just looks like the original texture. How can I get a nice, bright white highlight? (Say that 10 times fast!) Thanks in advance! :)

Share this post

Link to post
Share on other sites
OpenGL FAQ / 21 Texture Mapping

21.040 Lighting and texture mapping work pretty well, but why don't I see specular highlighting?

Your geometry may have a nice white specular highlight when it's not texture mapped, but when you apply a non-white texture suddenly the highlight goes away even though the geometry is still lit. This is because GL_MODULATE multiplies the primitive's lighting color components with the texture color components. For example, assume a white specular highlight is being multiplied by a red texture map. The final color is then (1.0*1.0, 1.0*0.0, 1.0*0.0) or (1.0, 0.0, 0.0), which is red. The white specular highlight isn't visible.

OpenGL 1.2 solves this problem by applying specular highlights after texture mapping. This separate specular lighting mode is turned on by:


By default, it's set to GL_SINGLE_COLOR, which maintains backwards compatibility with OpenGL 1.1 and earlier.

If you're not using OpenGL 1.2, other solutions are available. Many vendors provide proprietary extensions for allowing you to apply the specular highlight after the texture map. See this example code for how to do this on HP systems. Many OpenGL vendors have settled on an the EXT_separate_specular_color extension.

Another method works on any OpenGL implementation, because it only uses regular OpenGL 1.0 functionality and doesn't depend on extensions. You need to render your geometry in two passes: first with normal lighting and texture mapping enabled, then the second pass will render the specular highlight. See this example code for a demonstration of how to do it.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this