0
\$\begingroup\$

I have a parameter in HLSL shader in a constant buffer which is a float3x3. Is there is 3x3 matrix struct in Directx 11 or should I use 4x4 matrix instead, and if so, how?

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Be aware that a 3x3 matrix is not going to pack well into a cbuffer; trying to save storage in this manner is often a false optimization. \$\endgroup\$ May 15 '17 at 22:25
4
\$\begingroup\$

D3D11 itself doesn't have any matrix structures at all; you might be thinking of the DirectXMath library's matrix classes. It does have a 3x3 matrix type you can use.

In general, you can store a 3x3 matrix in the upper-left of a 4x4 matrix (setting the bottom-right-most element to 1) if that 3x3 is only storing scale and/or rotation in 3D. If you were storing a 2D translation in there or anything else, you'd have to rebuild the 4x4 matrix appropriately based on whatever data you were putting into the 3x3 matrix.

\$\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.