Why do we need to use "transpose" the transformed matrix? (Direct3D11)

I have read SimpleMath and also read the programmer 's guide , but I cannot seem to lean towards the goal of transferring a matrix when it has been "transformed"

I mean, I understand what matrix transposition is. I just don't understand why we need to take the transpose.

Take this piece of code for example .. (assuming matrices are already created for CameraView

and CameraProjection

)

World = XMMatrixIdentity();                             

WVP = World * CameraView * CameraProjection;

XMMatrixTranspose(WVP)      

      

So my question is, what is the purpose of getting the transposition WVP

? What is the purpose of this for Direct3D 11?

+3


source to share


1 answer


First, let's see how matrices can be represented in memory. Consider the following matrix.

1 2 3
4 5 6
7 8 9

      

All values ​​stored in the computer memory are stored sequentially, there is no concept of "row" and "column", only an address. If you represent the matrix above in row order, the float values ​​in the matrix will be stored linearly in memory like this:

Lowest address [1 2 3 4 5 6 7 8 9] Highest address



If, on the other hand, you represent this same matrix in column order, the float values ​​in the matrix will be stored in memory like this:

Lowest address [1 4 7 2 5 8 3 6 9] Highest address

So, in a high-order row, consecutive row values are contiguous in memory, whereas in a high-order column , consecutive column values are contiguous in memory.

HLSL now requires your matrices to be in basic order in order, but DirectXMath stores its matrices in row order because its implementation is faster, so you need to transpose it so that it hits the HLSL shaders in the main column.

+2


source







All Articles