I was just playing with HLSL . I want to get the vector "inputPos" in vector "pos". case2 is working but not case1 . why ? Aren't both the cases same ? M * M_Inv * inputPos = inputPos. Why case 1 is not giving right value?
//case 1
pos = mul( float4( inputPos, 1), c_mView ); // Line1
pos = mul ( pos , c_mViewInverse ); // Line2
//case2
pos = mul ( mul( float4( inputPos, 1), c_mView ) , c_mViewInverse );
thanks.
Probably in your case variable pos is float3,so if you don't provide the w component in the second operation that will mess up your calculation. (in case 2 you use the result of the first mul directly which will be a float4)
pos = mul( float4( inputPos, 1), c_mView );
pos = mul ( float4(pos,1) , c_mViewInverse );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With