I'm trying to multiply the transformation matrix in shader with vectors directly without doing unnecessary transportation. According to HLSL's mul
documentation:
mul(x, y)
Multipliesx
andy
using matrix math. The inner dimension x-columns and y-rows must be equal.
x [in]
Thex
input value. Ifx
is a vector, it treated as a row vector.
y [in]
They
input value. Ify
is a vector, it treated as a column vector.
I have in the C++ code:
const D3DXMATRIX viewProjection = view * projection;
...
const D3DXMATRIX modelViewProjection = model * viewProjection;
where modelViewProjection
is row-major order matrix that is copied to a constant buffer, not transposed. However, for this to work in the HLSL i need to multiply the transformation matrix with the position vector as:
output.position = mul(transformation, position);
which is the opposite of what the mul
documentation is saying.
Can someone explain where is the mismatch here?