Original Post
Whilst working on my deferred renderer, I've noticed the quality of my normals is well.... terrible. The problem is most noticable where there is a sudden change of elevation in the terrain, which is pretty common considering I'm using noise to generate it. The bottom left section below shows what I mean:
My normal map looks like this:
My normal map is generated using the following HLSL: I'm using linear sampling to get the normals from the normal map and display them on the screen. How can I improve my normal map generation to make it look less pixelated and remove this problem? Is it even possible? [Edited by - adt7 on June 10, 2009 1:43:47 PM]
My normal map looks like this:
My normal map is generated using the following HLSL: float topLeft = abs(tex2D (Elevation, uv + OneOverTextureSize * float2(-1.0f, -1.0f)).r);
float left = abs(tex2D (Elevation, uv + OneOverTextureSize * float2(-1.0f, 0.0f)).r);
float bottomLeft = abs(tex2D (Elevation, uv + OneOverTextureSize * float2(-1.0f, 1.0f)).r);
float top = abs(tex2D (Elevation, uv + OneOverTextureSize * float2( 0.0f, -1.0f)).r);
float bottom = abs(tex2D (Elevation, uv + OneOverTextureSize * float2( 0.0f, 1.0f)).r);
float topRight = abs(tex2D (Elevation, uv + OneOverTextureSize * float2( 1.0f, -1.0f)).r);
float right = abs(tex2D (Elevation, uv + OneOverTextureSize * float2( 1.0f, 0.0f)).r);
float bottomRight = abs(tex2D (Elevation, uv + OneOverTextureSize * float2( 1.0f, 1.0f)).r);
float dX = 3.0f * topLeft + 10.0f * left + 3.0f * bottomLeft - 3.0f * topRight - 10.0f * right - 3.0f * bottomRight;
float dY = 3.0f * topLeft + 10.0f * top + 3.0f * topRight - 3.0f * bottomLeft - 10.0f * bottom - 3.0f * bottomRight;
float3 normalf = normalize(float3(dX, dY, 1.0f));
normalf.xy = normalf.xy * 0.5f + 0.5f;
