HLSL Normal mapping, interpolation question

Started by
-1 comments, last by chevluh 12 years, 5 months ago
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.

This topic is closed to new replies.

Advertisement