Jump to content
  • Advertisement
Sign in to follow this  
chevluh

HLSL Normal mapping, interpolation question

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

I'm making a simple terrain engine, and have decided to use a normal map for per-pixel lighting. The normal map's in object space, and currently at a rather coarse resolution (256[sup]2[/sup]). It's dynamically generated using the terrain's gradient, and packed into a rgb texture. The pixel shader's really simple for now, it only outputs the dot product between normal and light direction.

float3 n = normalize(tex2D(NormalMapSampler, input.TexCoord).rgb * 2.0f - 1.0f);
float light = dot (n, -LightDirection);
float4 color = light;
return color;


And so I get this:

085af.png

To me that darker grid at texel boundaries looks a lot like the consequence of how the texture sampler's linearly interpolating the normal, but if I normalize it (as in the sample code) it does nothing (or at least nothing noticeable).

Now, is there something I'm missing or are smooth normal maps like that just not meant to work up close? It's not that much of a problem because the terrain's really going to use chunked LoD so the map should never be magnified that much, but I'd like to understand if there's some error here.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!