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
are scaled "wrongly". Please help me to understand why this is.
Thank you.
DirectX 9 + HLSL Matrix and non-uniform scaling
Started by david w, Sep 02 2012 04:18 PM
2 replies to this topic
Sponsor:
#2 Members - Reputation: 37
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.
-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.






