From 4815fe45f406ed65aecb6bd5988d972339406217 Mon Sep 17 00:00:00 2001 From: QuantumCoderQC Date: Sat, 7 Oct 2023 14:10:03 +0200 Subject: [PATCH] calculate normal matrix for billboards --- Sources/iron/object/Uniforms.hx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Sources/iron/object/Uniforms.hx b/Sources/iron/object/Uniforms.hx index 8cf81b2f..a24e268d 100644 --- a/Sources/iron/object/Uniforms.hx +++ b/Sources/iron/object/Uniforms.hx @@ -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));