Jump to content
  • Advertisement
Sign in to follow this  
aprilspirit89

How to orthogonalize to non-orthogonal matrix using HLSL

This topic is 2069 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

 

 

Share this post


Link to post
Share on other sites
Advertisement

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!