Sign in to follow this  
sgsrules

Combining Normal maps in a pixel shader

Recommended Posts

Whats the proper way to combine normal maps in a shader? I've tried two approaches so far and neither one seems to give me correct results. I've modulated the normals once using the following:
  vec3 nm=(texture2D(normalSampler,gl_TexCoord[0].st)).xyz;
  nm.xy=nm.xy*2.0-1.0;
  normal = normalize(nm.x * eyeSpaceTangent + nm.y * eyeSpaceBinormal + nm.z * eyeSpaceNormal);


and then applied the second normal map using the same function. It seemed like it worked at first but things where a bit off. I also tried adding the two normal maps, normalizing them and then applying them to the above function but it seems like the results are to "soft". after spending some time with google i wasn't able to find anything if someone could point me in the right direction that would be awesome. [Edited by - sgsrules on December 23, 2009 3:13:20 AM]

Share this post


Link to post
Share on other sites
figured out what the problem was i had to fix the range of each normal map individually with:

nm.xy=nm.xy*2.0-1.0;

and then add them and then normalize

[Edited by - sgsrules on December 23, 2009 3:52:49 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this