Specular Bumpmapping

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

Recommended Posts

I have made a simple diffuse bumpmapping with shaders, using normal map, now I am trying to add specular component to it, but if I do traditional specular component it looks ugly, How can I do specular bump, shining the cracks and bumps of the texture, and not only a specular white shining circle ? Thanks Edit: Which is the minimum version of PS and VS in which is possible to do Specular bumpmapping ? (i know that diffuse bumpmapping can be done in VS 1.1 and PS 1.1) [Edited by - q2guy on December 2, 2004 1:32:42 PM]

Share on other sites
Specular bump mapping is done the same way as diffuse: taking the normal from the normal map instead of the vertex normal. Instead of (N dot L) for diffuse lighting, the dotproduct between the normal map normal and the half angle vector H is taken, and exponentiated: (N dot H) ^ specularExponent. H is evalutaed in a vertex shader, and just as L, it must be in tangent space.

Other than the L vs. H issue and the exponent, there's really no difference between diffuse and specular bump mapping.

Share on other sites
I have code it like you told and it look good, thanks very much

Share on other sites
Good. There's a neat trick you might want to add the specular bump mapping, as it tends to make it look much nicer: gloss maps. Basically a greyscale map (you can put it into the alpha component of your rgb texture) that modulates the strength of the perpixel specularity at each pixel. That way, some parts of the model can be more shiny than others. With old style specularity this wasn't very important, but with specular bump mapping it can really add a lot to the realism.

Share on other sites
I have a problem doing it in rendermonkey, my card is gf4 (vs1.1,ps1.3), if I use HAL mode, i get only a plain diffuse texture, if I use REF device, the specular bumpmapping looks good (but not realtime, of course), why ?

Share on other sites
Quote:
 Original post by q2guyI have a problem doing it in rendermonkey, my card is gf4 (vs1.1,ps1.3), if I use HAL mode, i get only a plain diffuse texture, if I use REF device, the specular bumpmapping looks good (but not realtime, of course), why ?

On a guess, it might be the exponentiation, the geforce4 can't do that in a pixel shader. It must be emulated by consecutive multiplications. But post your code.

Share on other sites
Before post the code, I have some questions about diffuse bumpmapping correctness, I get slightly different result with simple ambiguous things:

1. Is the same:

   float3 N = mul(world,IN.Normal);   float3 T = mul(world,IN.Tangent);   float3 B = mul(world,cross(T,N));      float3 L;   L.x = dot(T,LightPos);   L.y = dot(B,LightPos);   L.z = dot(N,LightPos);   L = (L * 0.5) + 0.5;     OUT.TexCoord0.xy = IN.TexCoord.xy;   OUT.TexCoord1.xy = IN.TexCoord.xy;      OUT.Color.xyz = normalize(L.xyz);

and
   float3 N = mul(world,IN.Normal);   float3 T = mul(world,IN.Tangent);   float3 B = mul(world,cross(N,T));   // <=   float3 L;   L.x = dot(T,-LightPos);  // <=   L.y = dot(B,-LightPos);  // <=   L.z = dot(N,-LightPos);  // <=   L = (L * 0.5) + 0.5;     OUT.TexCoord0.xy = IN.TexCoord.xy;   OUT.TexCoord1.xy = IN.TexCoord.xy;      OUT.Color.xyz = -normalize(L.xyz); // <=
?

2. Must be L be normalized before encoded into [0,1] range, or after ? Must be N,T,B and LightPos be normalized ?

P.D.:
How can I post images directly here (no links) ?

   float3 N = 2.0f * (tex2D(Texture1,IN.TexCoord1.xy) - 0.5f);   float3 C = 2.0f * (IN.Diffuse - 0.5f);      float  NdotL = dot(N,C);   float4 tcol  = tex2D(Texture0,IN.TexCoord0.xy);   OUT.Color = NdotL * tcol;

Share on other sites
I believe that normal pointing out of object vertex position is (Binormal x Tangent) cross product, so Binormal = Tangent x Normal. Also I think you have to use light vector and not light direction, this is:

- Light vector: Light position - vertex position
- Light direction: normalized( vertex position - light position)

the same with view vector for the specular component.

Share on other sites
nitpick: its not a binormal, its a bitangent. why does everyone call it a binormal, that for circles and stuff!?

Share on other sites
circles and stuff??
http://mathworld.wolfram.com/BinormalVector.html

1. 1
Rutin
24
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 46
• 41
• 23
• 13
• Forum Statistics

• Total Topics
631749
• Total Posts
3002031
×