Specular Maps

Started by
1 comment, last by spek 16 years ago
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!
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.

Game Programming Blog: www.mattnewport.com/blog

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

This topic is closed to new replies.

Advertisement