HLSL mul() and row/column major matricies in directx

Started by
10 comments, last by Benjamin Loisch 9 years, 5 months ago

On the C++ side, the maths library that you're using will determine both the array storage convention and the mathematical convention.
What math library are you using?

I am using xnamath and it's matrices. I believe they are stored row-major because I must transpose them before sending them to the vertex shader. Now, in my vertex shader I have to use mul(vertex, matrix) because with mathematical "row-major" you go from left to right that is, vertex * world * view * projection. I know I must transpose the wvp because hlsl accepts matrices in its column-major storage.

Advertisement

hodgeman, buckeye, vstrahk, thnks for your help. I'm pretty sure I get it now. i used row_major in front of my float4x4 WVP matrix. i was able to send in my WVP matrix and have the mul(vertex, WVP) work just fine. I was also able to do mul(PtVtWt, vertex) and that worked just fine. PtVtWt being the reversed order matrix if you multiply with a column vector which mul(matrix, vector) does.

This topic is closed to new replies.

Advertisement