[SOLVED] supply the normal in World Space, not Tangent Space


photo

Recommended Posts

Hi, we are writing a custom deferred shader and we want to supply the normal in World Space, not Tangent Space. How can we achieve this? We do not want the value we supply in gbuffer.normal to be interpreted as if it was in Tangent Space.

/roberto

Link to post

Hi roberto.voxelfarm.

The main idea is deferred shader must return normal in view space. As I understand you want interpret normal map in world space. You should read normal from texture, then transform to view space with s_modelview.

float4 normal_map = TEXTURE_BASE_NORMAL(TEX_NORMAL);
GBUFFER.normal = normalize(mul3(s_modelview, normal_map));

roberto.voxelfarm

 

  • Like 1
Link to post

Thank you consta,

This work perfect.

Link to post
  • silent changed the title to [SOLVED] supply the normal in World Space, not Tangent Space