0
\$\begingroup\$

I have code that calculates a position like this in HLSL:

output.ShadowPos = input.VertexPos;
output.ShadowPos = mul(output.ShadowPos, gWorld);
output.ShadowPos = mul(output.ShadowPos, lightArray.lightView);
output.ShadowPos = mul(output.ShadowPos, lightArray.lightProject);
output.ShadowPos = mul(output.ShadowPos, T);

This works fine, but I would like to multiply the matrix together first

matrix m = gWorld * lightArray.lightView * lightArray.lightProject * T;
output.ShadowPos = input.VertexPos;
output.ShadowPos = mul(output.ShadowPos, m);

Yet this doesn't work, why?

\$\endgroup\$
3
\$\begingroup\$

Do your matrix multiplications like vector*matrix, like this:

matrix m = mul(gWorld,mul(lightArray.lightView,mul(lightArray.lightProject,T)));
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.