Skip to content

Commit 6fdc0c1

Browse files
Added MatrixFromRows() function to shader definitions
1 parent 5890150 commit 6fdc0c1

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

Graphics/GraphicsEngineD3DBase/include/HLSLDefinitions.fxh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,9 @@ float BoolToFloat( bool b )
5858

5959
#define MATRIX_ELEMENT(mat, row, col) mat[row][col]
6060

61+
float4x4 MatrixFromRows(float4 row0, float4 row1, float4 row2, float4 row3)
62+
{
63+
return float4x4(row0, row1, row2, row3);
64+
}
65+
6166
#endif // _HLSL_DEFINITIONS_

Graphics/GraphicsEngineD3DBase/include/HLSLDefinitions_inc.fxh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,9 @@
5858
"\n"
5959
"#define MATRIX_ELEMENT(mat, row, col) mat[row][col]\n"
6060
"\n"
61+
"float4x4 MatrixFromRows(float4 row0, float4 row1, float4 row2, float4 row3)\n"
62+
"{\n"
63+
" return float4x4(row0, row1, row2, row3);\n"
64+
"}\n"
65+
"\n"
6166
"#endif // _HLSL_DEFINITIONS_\n"

Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,11 @@ float DepthToNormalizedDeviceZ(float fDepth)
974974

975975
#define MATRIX_ELEMENT(mat, row, col) mat[col][row]
976976

977+
float4x4 MatrixFromRows(float4 row0, float4 row1, float4 row2, float4 row3)
978+
{
979+
return transpose(float4x4(row0, row1, row2, row3));
980+
}
981+
977982
// ---------------------------------- Vertex shader ----------------------------------
978983
#ifdef VERTEX_SHADER
979984

Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,11 @@
974974
"\n"
975975
"#define MATRIX_ELEMENT(mat, row, col) mat[col][row]\n"
976976
"\n"
977+
"float4x4 MatrixFromRows(float4 row0, float4 row1, float4 row2, float4 row3)\n"
978+
"{\n"
979+
" return transpose(float4x4(row0, row1, row2, row3));\n"
980+
"}\n"
981+
"\n"
977982
"// ---------------------------------- Vertex shader ----------------------------------\n"
978983
"#ifdef VERTEX_SHADER\n"
979984
"\n"

0 commit comments

Comments
 (0)