Skip to main content
GameDev.net gamedev.net
🔒 Locked

Combining Normal Maps for Terrain

Started by adt7 Jun 14, 2009 at 5:16 PM 1 replies 650+ views
Original Post
adt7
adt7
I've tried searching Google for this, but with no joy, I keep getting conflicting answers (plus it seems whenever I search for anything normal map related on Google the results are never great) Anyway. I have my terrain normal map, which is based on the height map. Then I have my normal map for the texture I'm applying to the terrain. How do I combine these in the pixel shader for my terrain so that the normals for the texture are offset by the correct angle due to the slopes of the terrain?
Matt Aufderheide
Matt Aufderheide
try something like this:

float3 addnormal=lerp(terrainnorm.rgb,detailnorm.rgb,0.3); //pick a lerp value
float distSq = 1 - (dot( 2 * (addnormal.xyz - 0.5), 2 * (addnormal.xyz - 0.5)));
addnormal = (distSq*(addnormal-0.5))+(2*(addnormal-0.5));
adt7
adt7
Is there are explanation to go along with that? Don't mean to be a pain, but I do like to understand the theory behind what I'm doing.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.