Hi,
I'm actually working on terrain rendering based on quadtree & GeoMip Terrain.
I've implemented normal maps generation by the GPU and everythings works fine except I'm getting artifacts near the ground.
I Get lines (cf screenshot) after the normal calculation wich is certainly a precision issue.
Heightmaps are 256^2, and shows no artifacts.
Normal Maps are 256^2 and artifacts shows at ground level (Quadtree depth is 16 and above.)
Both are R32G32B32A32_FLOAT textures.
If anyone has an idea or experienced those kind of artifacts, I'll be grateful
Here is my normalMap HLSL code (with scale coming from CPU : f32 scale = 1<<pTreeNode->GetDepth(); );
float2 uv = input.tex0;
float3 sphere = heightMap.Sample(heightMapSamplerState, uv).xyz;
float hpix = PixelSize;
float normalStrength = 0.5;
float l = heightMap.Sample(heightMapSamplerState, uv + float2( -hpix, 0)).w;
float r = heightMap.Sample(heightMapSamplerState, uv + float2( hpix, 0)).w;
float t = heightMap.Sample(heightMapSamplerState, uv + float2( 0, hpix)).w;
float b = heightMap.Sample(heightMapSamplerState, uv + float2( 0, -hpix)).w;
float tanZ = (t-b);
float tanX = (l-r);
float tanY = 2.0 / (scale*normalStrength);
float3 normal = normalize(float3(tanX, tanY, tanZ)) * 0.5 + 0.5;
float ny = normal.y;
float3x3 mat = BuildRotationMatrix(sphere, float3(0.0f, 1.0f, 0.0f));
normal = mul(normal.xzy, mat); //FaceMatrix
return float4(normal, ny);