I know how to make a WorldToTangentSpace matrix, but how do I get Tangent to World?

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

Recommended Posts

Hi, I have a vertex shader in which I use a 3x3 matrix to transform from World to Tangent space. It looks like this: float3x3 WorldToTangentSpace; WorldToTangentSpace[0] = float3(0.0f, 0.0f, -1.0f); WorldToTangentSpace[1] = float3(0.0f, -1.0f, 0.0f); WorldToTangentSpace[2] = Normal; And then to transform from World to Tangent space I do this: float3 TangentVector = mul(WorldToTangentSpace, WorldVector); It works correctly. But what if I want to do the opposite, transform from Tangent Space to World Space? Do I reverse the multiplication, like this: float3 WorldVector = mul(TangentVector, WorldToTangentSpace); Or must I create a new (inverted) matrix? What is the correct math to do this? Peter

Share on other sites
You need to solve a system of linear equations. One conceptually simple way of doing that is by inverting the matrix.

If x and b are column vectors and A is a matrix, you want to solve

A * x = b

Multiplyng by inv(A) on the left of both sides of the equation you get

x = inv(A) * b

Share on other sites
When your matrix is rotations and reflections, the inverse matrix is the matrix transpose. If you think about it a little, that's not too hard to see. The key is that rotations preserve orthogonality.

http://en.wikipedia.org/wiki/Orthogonal_matrix

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 13
• 14
• 9
• Forum Statistics

• Total Topics
633365
• Total Posts
3011523
• Who's Online (See full list)

There are no registered users currently online

×

Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!