Skip to content

Commit

Permalink
Merge pull request #200 from QuantumCoderQC/fix-billboarding
Browse files Browse the repository at this point in the history
Calculate normal matrix for billboards
  • Loading branch information
luboslenco committed Oct 10, 2023
2 parents 13155c8 + 4815fe4 commit 21ddde4
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Sources/iron/object/Uniforms.hx
Expand Up @@ -939,6 +939,34 @@ class Uniforms {
helpMat3.setFrom4(helpMat);
m = helpMat3;
}
case "_normalMatrixSphere": {
helpMat.setFrom(object.transform.world);
// Align to camera..
helpMat.multmat(camera.V);
helpMat._00 = 1.0; helpMat._10 = 0.0; helpMat._20 = 0.0;
helpMat._01 = 0.0; helpMat._11 = 1.0; helpMat._21 = 0.0;
helpMat._02 = 0.0; helpMat._12 = 0.0; helpMat._22 = 1.0;
helpMat2.getInverse(camera.V);
helpMat.multmat(helpMat2);
helpMat2.getInverse(helpMat);
helpMat2.transpose3x3();
helpMat3.setFrom4(helpMat2);
m = helpMat3;
}
case "_normalMatrixCylinder": {
helpMat.setFrom(object.transform.world);
// Align to camera..
helpMat.multmat(camera.V);
helpMat._00 = 1.0; helpMat._20 = 0.0;
helpMat._01 = 0.0; helpMat._21 = 0.0;
helpMat._02 = 0.0; helpMat._22 = 1.0;
helpMat2.getInverse(camera.V);
helpMat.multmat(helpMat2);
helpMat2.getInverse(helpMat);
helpMat2.transpose3x3();
helpMat3.setFrom4(helpMat2);
m = helpMat3;
}
case "_viewMatrix3": {
#if arm_centerworld
helpMat3.setFrom4(vmat(camera.V));
Expand Down

0 comments on commit 21ddde4

Please sign in to comment.