16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 09:19:18 +02:00

Merge pull request #111 from MaSzyna-EU07/opengl-instancing

Some rendering improvements
This commit is contained in:
2026-06-16 23:09:12 +02:00
committed by GitHub
14 changed files with 776 additions and 60 deletions

View File

@@ -81,7 +81,12 @@ namespace gl
void set_modelview(const glm::mat4 &mv)
{
modelview = mv;
modelviewnormal = glm::mat3x4(glm::mat3(glm::transpose(glm::inverse(mv))));
// normal matrix = transpose(inverse(modelview)). The modelview is
// always affine, so its 3x3 normal matrix depends only on the
// upper-left 3x3 block; inverting that mat3 directly is markedly
// cheaper than a full mat4 inverse and yields an identical result
// (for affine M, mat3(inverse(M)) == inverse(mat3(M))).
modelviewnormal = glm::mat3x4(glm::transpose(glm::inverse(glm::mat3(mv))));
}
};