Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


World space to tangent space


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Jeason   Members   -  Reputation: 96

Like
0Likes
Like

Posted 02 March 2012 - 02:42 AM

// Normalize the light and view vectors and transform it to the tangent space:
    float3x3 mWorldToTangent = float3x3( vTangentWS, vBinormalWS, vNormalWS );

// Propagate the view and the light vectors (in tangent space):
    Out.vViewTS  = mul( mWorldToTangent, vViewWS  );
    Out.vLightTS = mul( vLightWS, mWorldToTangent );

vLightWS, vViewWS is the lgith vector and view vector in world space.

My question is that the last two line codes are doing the same operation but with inverse order to multiply matrix. I think the last is wrong, but the program runs well. Why?

Sponsor:

#2 programci_84   Members   -  Reputation: 336

Like
0Likes
Like

Posted 02 March 2012 - 07:33 AM

What can you say about a float3? Is it a 3x1 or 1x3 matrix?

I think that "mul" function deals with that difference.
There's no "hard", and "the impossible" takes just a little time.

#3 Jeason   Members   -  Reputation: 96

Like
0Likes
Like

Posted 03 March 2012 - 09:38 PM

Thank you, programci_84.
But i dont get it.

I think the variable "mWorldToTangent" may be not right if it will be used to multiply a vector at the right side of mul function.
Because mul() function give different result according to the position of params.

We can see mul( mWorldToTangent, vViewWS ) != m( vViewWS, mWorldToTangent ).

So the last codes is not right, isn't it?

#4 Hodgman   Moderators   -  Reputation: 31786

Like
0Likes
Like

Posted 03 March 2012 - 10:53 PM

Out.vLightTS = mul( vLightWS, mWorldToTangent );
is the same as
Out.vLightTS = mul( transpose(mWorldToTangent), vLightWS );
and in the case of pure 3x3 rotation matrices
transpose(rotation) == inverse(rotation)

So what that code is doing is multiplying by the inverse of that rotation matrix.

If vLightWS and vViewWS are both in world-space, then yes, the code looks fishy, as one is being transformed by a TBN rotation and one by the inverse...

#5 Jeason   Members   -  Reputation: 96

Like
0Likes
Like

Posted 04 March 2012 - 01:30 AM

Yes, Hodgman.

So the last codes ---Out.vLightTS = mul( vLightWS, mWorldToTangent ), is wrong? Do you think so?

But the program runs well with the last code. Why? Who can tell me?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS