Jump to content
  • Advertisement
Sign in to follow this  
PeterV

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.

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

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 this post


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


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!