• Advertisement
Sign in to follow this  

Specular Maps

This topic is 3608 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, I'm trying to load a model that contains a specular map. I'm semi-familiar with the basic formula for computing specular lighting (although if anyone has a good refresher link, I'd love to review my stuff), but I've never dealt with a specular map. Does a specular map replace specular lighting, or does it simply influence the results of the specular lighting by providing a bias? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Usually a specular map just modulates the final brightness of the specular for the pixel/fragment - calculate the specular lighting as normal and then multiply by the value from the specular map (which may be a scalar or an rgb value) to get the final specular contribution.

Specular map might also sometimes refer to a map that is used to vary the specular exponent across the surface but that is usually called a gloss map.

Share this post


Link to post
Share on other sites
specularColor = specularColor * tex2D( specularMap, texcoords );

That's all. Or eventually you also encode the 'shininess' value into the specularMap (alpha channel) like Mattnewport told. Just like you can vary the normal per pixel with a normalMap, you can vary the specularColor per pixel.

For example, you have a texture with skin, metal, and red plastic on it. The skin pixels should reflect different than metal and plastic. You might want to give the skin a little redish value, while blue for metal, and red for the red plastic. Metal and plastic will also reflect stronger than skin, so their pixel colors are more intense. Doom3 and Quake4 did this trick alot.

In practice you won't need this trick that much. I ussually only encode the specular intensity in the alpha channel from the normalMap. So:
specularColor *= normalMap.a * overallSpecularColor;
In this case, each pixel won't have an individual RGB color, only an intensity factor. The overallSpecularColor is 1 RGB color for the entire object/texture.

It's a little bit faster, and saves 1 texture. It works good enough, unless you really have different materials in the same texture.

Greetings,
Rick

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement