View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# How to orthogonalize to non-orthogonal matrix using HLSL

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

### #1Tunisia hawker  Members

Posted 24 January 2013 - 10:11 PM

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.

And this is the wrong result of orthogonalize the origin matrix and then using the inverse-transpose one and do lighting in tangent space.

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));
}


### #2hdxpete  Members

Posted 25 January 2013 - 12:04 AM

you have the matrix you are sending to the shader right? can't you do it in C++ code and send the resulting matrix as an extra parameter to the shader?

### #3Tunisia hawker  Members

Posted 25 January 2013 - 12:36 AM

you have the matrix you are sending to the shader right? can't you do it in C++ code and send the resulting matrix as an extra parameter to the shader?

I can't.The matrix itself was generate in shader.In fact, I 'm trying to do normal mapping without precomputed tangent attribute in vertex buffer.The technique can be found in ShaderX5, Chapter2.6.It provides a non-orthogonal tangent-to-local matrix,so I'm trying to get the local-to-tangent matrix so that I can do lighting calculations in tangent space.

Edited by Tunisia hawker, 25 January 2013 - 12:36 AM.

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.