View Issue Details

IDProjectCategoryView StatusLast Update
0006279The Dark ModCodingpublic29.03.2023 21:19
Reporterstgatilov Assigned Tostgatilov  
PrioritynormalSeveritytextReproducibilityN/A
Status resolvedResolutionfixed 
Product VersionTDM 2.11 
Target VersionTDM 2.12Fixed in VersionTDM 2.12 
Summary0006279: Clarify matrix conventions in the code
DescriptionRecently I got confused by how various matrices are used.
The goal is to understand it, and fix any wrong usage.
Additional InformationSee also forum thread:
  https://forums.thedarkmod.com/index.php?/topic/21803-matrix-conventions/
TagsNo tags attached.

Activities

stgatilov

stgatilov

29.03.2023 20:48

administrator   ~0015981

I have written detailed investigation on forums:
  https://forums.thedarkmod.com/index.php?/topic/21803-matrix-conventions/
I copy the verdicts below.

idRenderMatrix from Doom 3 BFG:
    row-major layout, indexed as A[row][column]
    transformed vector is column-vector on the right
    A then B composition is (B * A)

idMat4, idMat2:
    row-major layout, indexed as A[row][column]
    transformed vector is column-vector on the right
    vector-matrix and matrix-vector multiplications yield same result
    A then B composition is (B * A)

idMat3:
    column-major layout, indexed as A[column][row]
    vector-matrix and matrix-vector multiplications yield same result
    A then B composition is invoked like A * B in the C++ code
In a sense, idMat3 just stores transposed matrix compared to idMat4...

GLSL/OpenGL matrices:
    column-major layout, indexed as A[column][row]
    transformed vector is column-vector on the right
    vec * mat is same as transpose(mat) * vec
    A then B composition is (B * A)

float[16] in Doom 3 renderer backend:
    column-major layout
    transformed vector is column-vector on the right
    A then B composition is myGlMultMatrix(A, B)
stgatilov

stgatilov

29.03.2023 21:19

administrator   ~0015982

Added a bit more docs to the code:
  r10334 Added some comments regarding matrix conventions.
And fixed the mess with idMat4 in backend:
  r10337 Fixed confusion of passing idMat4 to GLSL without transpose.

Issue History

Date Modified Username Field Change
29.03.2023 20:37 stgatilov New Issue
29.03.2023 20:41 stgatilov Additional Information Updated
29.03.2023 20:48 stgatilov Note Added: 0015981
29.03.2023 21:19 stgatilov Note Added: 0015982
29.03.2023 21:19 stgatilov Assigned To => stgatilov
29.03.2023 21:19 stgatilov Status new => resolved
29.03.2023 21:19 stgatilov Resolution open => fixed
29.03.2023 21:19 stgatilov Fixed in Version => TDM 2.12