Hi all.
Is the _Object2World Matrix Orthogonal ? I mean , Is the Inverse Transpose of _Object2World is equal to _Object2World Matrix ? , Is it true that :
_Object2World = Inverse Transpose (_Object2World ) //is orthogonal ?
I had test these two last lines of shaders for normal’s vector transformation and I had got same result : ( one of them has been commented, and also both of them works correct.)
V2F vertexProgram(vertexInput input)
{
V2F output;
float4x4 modelMatrix = _Object2World;
float4x4 modelMatrixInverse = _World2Object;
float4x4 modelMatrixInverseTranspose = transpose(modelMatrixInverse);
output.viewDir = float3(mul(modelMatrix, input.vertex) -
float4(_WorldSpaceCameraPos, 1.0));
//****THESE TWO LINES GIVE SAME RESULT.***//
//output.normalDir = mul(_Object2World,float4(input.normal,0));
output.normalDir = mul(modelMatrixInverseTranspose,float4(input.normal,0));
}
Because both of the below lines works correct, I had concluded that the _Object2World is an orthogonal matrix.
output.normalDir = mul(_Object2World,float4(input.normal,0));
output.normalDir = mul(modelMatrixInverseTranspose,float4(input.normal,0));
Am I going wrong ?
Thanks in advance.