我只是在玩HLSL。我想得到向量"pos“中的向量"inputPos”。case2工作正常,但case1不工作。为什么?这两种情况不都是一样的吗?M* M_Inv * inputPos = inputPos。为什么案例1没有给出正确的值?
//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 );谢谢。
发布于 2012-09-10 22:28:41
在本例中,变量pos可能是float3,所以如果在第二个操作中不提供w分量,将会使计算变得混乱。(在第二种情况下,您直接使用第一个mul的结果,它将是一个float4)
pos = mul( float4( inputPos, 1), c_mView );
pos = mul ( float4(pos,1) , c_mViewInverse ); https://stackoverflow.com/questions/12280031
复制相似问题