• Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

# DirectX 9 + HLSL Matrix and non-uniform scaling

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.

2 replies to this topic

### #1david w  Members   -  Reputation: 146

Like
0Likes
Like

Posted 02 September 2012 - 04:18 PM

I have a quesion about why if I use the world matrix in hlsl like so:

output.TBN[0] = normalize(mul(input.Tangent, (float3x3)World));
output.TBN[1] = normalize(mul(input.Binormal, (float3x3)World));
output.TBN[2] = normalize(mul(input.Normal, (float3x3)World ));

my normals are "scaled" correctly along with the mesh even if it is non-uniform scaling.

However if I do this:

output.TBN[0] = mul(Input.Tangent, (float3x3)WorldInverseTranspose);
output.TBN[1] = mul(Input.Binormal, (float3x3)WorldInverseTranspose);
output.TBN[2] = mul(Input.Normal, (float3x3)WorldInverseTranspose );

It works perfectly fine when using a uniform scale but not when non-uniform scaling is used. The normals

Thank you.

### #2JohnnyCode  Members   -  Reputation: 37

Like
0Likes
Like

Posted 03 September 2012 - 03:56 PM

-the rotation part of a world matrix is stored at 3x3 portion,- it does not scale vectors and keeps their original length, it only rotates them.
-the transformation part is 4th column so it does not matter in your case.
- the scale part is at the diagonal, so if scale is applied, it then prolongs the transformed vectors.

Just as you said, if you do not apply scale, and keeps it uniform, you can transform vectors without normalizing them. If scale is not 1.0 then you have to normalize vectors after transforming them by rotation part of the world matrix.

The inverse of the world matrix keeps all those properties.

### #3david w  Members   -  Reputation: 146

Like
0Likes
Like

Posted 03 September 2012 - 09:08 PM

Thank you for the information, it makes more sense to me know. I figured that the anwser was something along the lines of how you explained it.

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