# 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.

## 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 on other sites
mat3 TBN = mat3(tangent, binormal, normal);
normal = (TBN * nm);

##### 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]

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
18
5. 5

• 9
• 33
• 13
• 13
• 10
• ### Forum Statistics

• Total Topics
632582
• Total Posts
3007216

×