Jump to content
  • Advertisement
Sign in to follow this  
pierceblaylock

What are specular maps?

This topic is 3789 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

Hi, I'm just wondering what a specular map is exactly? I have some here with their diffuse and normal map texture counterparts. But I don't know what they are exactly. I figure they are used to produce some sort of specular highlight. What is the difference between using a specular map or just doing specular lighting in the shader? Also, what is the concept behind using a specular map in a shader? I have a shader set up to render vertices using a diffuse texture and a normal map for per pixel lighting. Where does the specular map fit into this process? I'm not looking for exact shader code (although I won't turn it down), I'm just after the concept of what I do with the specular map in the shader. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
The specular made is used to alter the spec value per texel. People have shiny bald heads, and not so shiny stubble on their chins. A belt buckle has a different spec value then the belt, and the jeans.

Share this post


Link to post
Share on other sites
When doing lighting, you calculate the diffuse term, and, if the object is "shiny", a specular term as well. The lightspot on a billiard ball is a typical example of specular lighting.

The whole ball is made of the same material. So the reflection is the same on all places. But what if the object is made of multiple materials that have different light reflection behavuar? Vampyre_Dark gave some examples. That belt for example, leather will reflect differently than the metal knobs/buckle on it.
- More/less reflection
- The reflection color (white, blueish, brownish, etc.)
- Shininess (how is the reflection spread out? A small spot, or all over the surface?)

You can encode these values per pixel in a texture. The same principle as a normal map. I ussually take the alpha channel in a normalMap as the reflection intensity factor ( finalSpecular *= normalMapPixel.alpha ). But if you want, you can also take a RGB(A) texture. Where RGB is the specular color/intensity, and alpha the shininess factor for example.

The calculation of the specular light stays the same in the shader. The only difference is that some of the values are variable and come from a texture now:
specularMapPixel = tex2D( specularMap, uv ).rgba;
specularColor.rgb = specularMapPixel.rgb;
shininess = specularMapPixel.a;
specular = pow( dot(reflectVector, lightDir) , shininess ) * specularColor.rgb * lightSpecularColor.rgb;

Greetings,
Rick

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!