Terrain normal map

Started by
0 comments, last by kauna 11 years, 8 months ago
Hi,

I am trying to figure out, how to render a terrain with my deffered lighting and i still have problems with normal map.

I am passing my terrain blocks into vertex shader, where i read heightmap texture to set heights to verticles.
I have also normal map, which was generated in LT3D software.

It seems, normal map from LT3d is in tangent space. I tried to convert it into world space by this formula:

float3 normal = NormalTexture.SampleLevel( ss, input.texnorm, 0 ).xyz;
normal = float3(0,0,1)*normal.x + float3(1,0,0)*normal.y + float3(0,1,0)*normal.z;
normal = normalize(normal * 2 - 1);

All terrain normals "shows" green colours mostly .. and that's still wrong.

What i need to get normals working ? I read somewhere in this forum, i don't need tangents and bitangents as terrain is not rotating.

Thank you smile.png

DirectX 11, C++

Advertisement
You don't need tangents or bitangents since the tangent space equals your world space in this particular case, unless you decide to add detail normal maps.

You seem to be doing some sort of swizzling with the components,

the code normal = float3(0,0,1)*normal.x + float3(1,0,0)*normal.y + float3(0,1,0)*normal.z is equal to normal = normal.yzx;

Use the swizzling which corresponds to your needs : y-up or z-up.

Otherwise, do you use world space or view space normals with your deferred renderer?

Cheers!

This topic is closed to new replies.

Advertisement