• Create Account

## Terrain normal map

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1wh1sp3rik  Members

248
Like
0Likes
Like

Posted 11 August 2012 - 11:06 AM

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

Edited by wh1sp3rik, 11 August 2012 - 02:15 PM.

DirectX 11, C++

### #2kauna  Members

2918
Like
0Likes
Like

Posted 13 August 2012 - 12:13 PM

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!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.