# HLSL Normal mapping, interpolation question

This topic is 2896 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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

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.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 12
• 9
• 11
• 15