Hi,I'm just wondering whether this can be done in ps shader.I have an non-orthogonal matrix and need to orthogonalize it and using inverse-?transpose result.I turned to matlab for help,only found their instructions a bit of complicated for shaders.It might influence the performance.So is there a solution yet?Thanks for any reply:)
PS:Image below shows the result of using origin matrix and do lighting in world space.
[attachment=13379:Right.png]
And this is the wrong result of orthogonalize the origin matrix and then using the inverse-transpose one and do lighting in tangent space.
[attachment=13380:wrong.jpg]
And here is my Orthogonalization code.
float3x3 Orthogonalization_Schmidt(float3x3 OrginMatrix)
{
float3 a1 = OrginMatrix[0];
float3 a2 = OrginMatrix[1];
float3 a3 = OrginMatrix[2];
float3 b1 = a1;
float3 b2 = a2 - dot(a2,b1)/dot(b1,b1)*b1;
float3 b3 = a3 - dot(a3,b1)/dot(b1,b1)*b1 - dot(a3,b2)/dot(b2,b2)*b2;
return float3x3(normalize(b1),normalize(b2),normalize(b3));
}