• ### What is your GameDev Story?

#### Archived

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

# Normal from tangent to world space

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

## 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 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 on other sites
This might help:

http://www.joecodegood.com/articles/abducted/p1/p4.html

##### 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 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]

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634089
• Total Posts
3015426
×