Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 25 Jul 2013
Offline Last Active Aug 03 2016 10:15 AM

#5081468 GPU Normal Maps Artifacts on a Quadtree Terrain

Posted by on 29 July 2013 - 09:17 AM

I think it's definitely a precision problem from the GPU to deal with too small values from the HeightMap.



If anyone have a clue for me smile.png

Attached Thumbnails

  • nmartefact1.jpg
  • nmartefact2.jpg

#5081384 GPU Normal Maps Artifacts on a Quadtree Terrain

Posted by on 29 July 2013 - 02:22 AM



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 tongue.png



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);

Attached Thumbnails

  • normalmapartefacts.jpg