Skip to main content
GameDev.net gamedev.net
🔒 Locked

What are specular maps?

Started by pierceblaylock Feb 7, 2008 at 3:15 AM 1 replies 60k views
Original Post
pierceblaylock
pierceblaylock
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.
Daaark
Daaark
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.
spek
spek
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.