Sign in to follow this  

Terrain normal map

This topic is 1982 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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:
[CODE]
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);
[/CODE]
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 [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by wh1sp3rik

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

This topic is 1982 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this