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.
What are specular maps?
Started by pierceblaylock, Feb 06 2008 09:15 PM
2 replies to this topic
#3 Prime Members - Reputation: 1174
Posted 07 February 2008 - 12:50 AM
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
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







