Jump to content

  • Log In with Google      Sign In   
  • Create Account


pbobzebuilder

Member Since 25 Jul 2013
Offline Last Active Yesterday, 03:32 PM

Topics I've Started

Equivalent to D3DReflect for OpenGL

19 November 2013 - 03:27 AM

Anyone knows if there's an equivalent to D3DReflet for Opengl ?

 

D3dReflect allows to Query the shader needs after compilation.

 


GPU Normal Maps Artifacts on a Quadtree Terrain

29 July 2013 - 02:22 AM

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

PARTNERS