Archived

This topic is now archived and is closed to further replies.

Lightrocker

Normal from tangent to world space

Recommended Posts

Hi, I use a pixel shader in version 2.0 to load a normal from a texture map. It should should point to the light, which is stored in a cube map. But the normal is in tangent space, so I need to transform it to world space to get the correct texture coordinate for the cube map. How can I do this? I know how to use tangent, binormal and normal as a matrix to transform a normal from world to tangent space, but it is not possible to invert this matrix in a pixel shader, is it? Is there another way? Thanks, Ronny Burkersroda

Share this post


Link to post
Share on other sites
why do you want to do that? Normally you don''t transform the normal to tangent space, since it''s already in tangent space (probably from your bumpmap), you transform the vector that points to your light to tangent space, in your vertex shader.

My Site

Share this post


Link to post
Share on other sites
You are right: My normal is already in tangent space, but I do not want to do dot-3-lighting. So I need no light direction in tangent space.
My light information is stored in a cube map like HDR mapping. To access a cube map I need the normal in world space. It is easy to do it in a vertex shader: All I need is to transform a vertex normal from object to world space and use the result as texture coordinate for the cube map. But in a pixel shader with normal map in tangent space I have to transform the normal from tangent to object and then to world space or directly from tangent to world space.
But how can I do that?

Share this post


Link to post
Share on other sites
You could include another matrix in your vertex (or maybe calculate it in your vertex program) that transforms from tangent space to world space (just the inverse of the normal-binormal-tangent matrix), and then transform the normal with it in the pixel shader.

My Site

[edited by - Quasar3D on January 23, 2004 8:05:54 AM]

Share this post


Link to post
Share on other sites