Jump to content
  • Advertisement
Sign in to follow this  

multiplying by identity matrix in Cg/HLSL

This topic is 4135 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

I just wanted to test whether my shader works ok, so I checked whether multiplying vertex position by identity matrix yields original position. Well, it does not... //identity matrix: float3x4 mat = (1,0,0,0, 0,1,0,0, 0,0,1,0); //IN.position is incoming vertex position as float4 float3 position = mul(mat, IN.position); //OUT.position is a float4 OUT.position = mul(model_view_proj, float4(position, 1.0f)); Without multiplication by mat the object is where it is supposed to be, with multiplication it disappears.

Share this post


Link to post
Share on other sites
Advertisement
Well, it seems that you cannot specify matrices as I did.
This works ok:
float3x4 mat;
mat[0] = float4(1,0,0,0); mat[1] = float4(0,1,0,0); mat[2] = float4(0,0,1,0);

Btw. in my opinion the Cg User Manual is a poor documentation of the language.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!