Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


#ActualBornToCode

Posted 03 July 2013 - 01:42 PM

 

I store my matrix like that :

m16[ 0 ] = 1.0f; m16[ 4 ] = 0.0f; m16[ 8  ] = 0.0f; m16[ 12 ] = x;
m16[ 1 ] = 0.0f; m16[ 5 ] = 1.0f; m16[ 9  ] = 0.0f; m16[ 13 ] = y;
m16[ 2 ] = 0.0f; m16[ 6 ] = 0.0f; m16[ 10 ] = 1.0f; m16[ 14 ] = z;
m16[ 3 ] = 0.0f; m16[ 7 ] = 0.0f; m16[ 11 ] = 0.0f; m16[ 15 ] = 1.0f;

I have renderer on Direct3D11 and OpenGL, and I have to transpose to have it works on D3D11.

I don't understand what you said about one matrix who works for all, maybe one #ifdef who change index ?

 

The reason why you need to transpose your matrix for d3d11 it is because the shader matrix memory layout is the transpose of the matrix layout you have store on the CPU side by default. So instead of 12,13,14. The element at 3,7,11 represent position.  But in OpenGL GLSL shaders the matrix layout is the same at the one you have on the CPU side, which is why there is no need to transpose for GLSL.


#4BornToCode

Posted 03 July 2013 - 01:41 PM

 

I store my matrix like that :

m16[ 0 ] = 1.0f; m16[ 4 ] = 0.0f; m16[ 8  ] = 0.0f; m16[ 12 ] = x;
m16[ 1 ] = 0.0f; m16[ 5 ] = 1.0f; m16[ 9  ] = 0.0f; m16[ 13 ] = y;
m16[ 2 ] = 0.0f; m16[ 6 ] = 0.0f; m16[ 10 ] = 1.0f; m16[ 14 ] = z;
m16[ 3 ] = 0.0f; m16[ 7 ] = 0.0f; m16[ 11 ] = 0.0f; m16[ 15 ] = 1.0f;

I have renderer on Direct3D11 and OpenGL, and I have to transpose to have it works on D3D11.

I don't understand what you said about one matrix who works for all, maybe one #ifdef who change index ?

 

The reason why you need to transpose your matrix for d3d11 it is because the shader matrix memory layout is the transpose of the matrix layout you have store on the CPU side by default. So instead of 12,13,14. The element at 3,7,11 represent position.


#3BornToCode

Posted 03 July 2013 - 01:40 PM

 

I store my matrix like that :

m16[ 0 ] = 1.0f; m16[ 4 ] = 0.0f; m16[ 8  ] = 0.0f; m16[ 12 ] = x;
m16[ 1 ] = 0.0f; m16[ 5 ] = 1.0f; m16[ 9  ] = 0.0f; m16[ 13 ] = y;
m16[ 2 ] = 0.0f; m16[ 6 ] = 0.0f; m16[ 10 ] = 1.0f; m16[ 14 ] = z;
m16[ 3 ] = 0.0f; m16[ 7 ] = 0.0f; m16[ 11 ] = 0.0f; m16[ 15 ] = 1.0f;

I have renderer on Direct3D11 and OpenGL, and I have to transpose to have it works on D3D11.

I don't understand what you said about one matrix who works for all, maybe one #ifdef who change index ?

 

The reason why you need to transpose your matrix for d3d11 it is because the shader matrix memory layout is the transpose of the matrix layout you have store on the CPU side by default. So instead of 12,13,14. The element at 3,7,11 represent position.


#2BornToCode

Posted 03 July 2013 - 01:38 PM

 

I store my matrix like that :

m16[ 0 ] = 1.0f; m16[ 4 ] = 0.0f; m16[ 8  ] = 0.0f; m16[ 12 ] = x;
m16[ 1 ] = 0.0f; m16[ 5 ] = 1.0f; m16[ 9  ] = 0.0f; m16[ 13 ] = y;
m16[ 2 ] = 0.0f; m16[ 6 ] = 0.0f; m16[ 10 ] = 1.0f; m16[ 14 ] = z;
m16[ 3 ] = 0.0f; m16[ 7 ] = 0.0f; m16[ 11 ] = 0.0f; m16[ 15 ] = 1.0f;

I have renderer on Direct3D11 and OpenGL, and I have to transpose to have it works on D3D11.

I don't understand what you said about one matrix who works for all, maybe one #ifdef who change index ?

 

The reason why you need to transpose your matrix for d3d11 it is because the shader matrix memory layout is the transpose of the matrix layout you have store on the CPU side by default.


#1BornToCode

Posted 03 July 2013 - 01:33 PM

 

I store my matrix like that :

m16[ 0 ] = 1.0f; m16[ 4 ] = 0.0f; m16[ 8  ] = 0.0f; m16[ 12 ] = x;
m16[ 1 ] = 0.0f; m16[ 5 ] = 1.0f; m16[ 9  ] = 0.0f; m16[ 13 ] = y;
m16[ 2 ] = 0.0f; m16[ 6 ] = 0.0f; m16[ 10 ] = 1.0f; m16[ 14 ] = z;
m16[ 3 ] = 0.0f; m16[ 7 ] = 0.0f; m16[ 11 ] = 0.0f; m16[ 15 ] = 1.0f;

I have renderer on Direct3D11 and OpenGL, and I have to transpose to have it works on D3D11.

I don't understand what you said about one matrix who works for all, maybe one #ifdef who change index ?

 

The reason why you need to transpose your matrix for d3d11 it is because the shader matrix memory layout is the transpose of the matrix layout you have store on the CPU side. For example instead of 12,13,14 for translation the shader matrix translation is stored at 3,7,11


PARTNERS