Jump to content
  • Advertisement
Sign in to follow this  
sgsrules

Combining Normal maps in a pixel shader

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

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!