From 64cad8dc1de829d1ce89cfff36d11acf5feff34d Mon Sep 17 00:00:00 2001 From: Jeshurun Hembd Date: Tue, 3 Oct 2023 19:21:20 -0400 Subject: [PATCH 1/5] Fix scaling of UniformState.normal --- packages/engine/Source/Renderer/UniformState.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/engine/Source/Renderer/UniformState.js b/packages/engine/Source/Renderer/UniformState.js index 4447269e10d7..42262cb269dd 100644 --- a/packages/engine/Source/Renderer/UniformState.js +++ b/packages/engine/Source/Renderer/UniformState.js @@ -1513,7 +1513,6 @@ function cleanNormal(uniformState) { const m = uniformState._normal; Matrix4.getMatrix3(uniformState.inverseModelView, m); - Matrix3.getRotation(m, m); Matrix3.transpose(m, m); } } From 9b04518d67d2e492d161b9eae3ec6797e300e47c Mon Sep 17 00:00:00 2001 From: Jeshurun Hembd Date: Tue, 3 Oct 2023 19:55:14 -0400 Subject: [PATCH 2/5] Fix scaling of UniformState.normal3D --- packages/engine/Source/Renderer/UniformState.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/engine/Source/Renderer/UniformState.js b/packages/engine/Source/Renderer/UniformState.js index 42262cb269dd..5b20e9e5c70a 100644 --- a/packages/engine/Source/Renderer/UniformState.js +++ b/packages/engine/Source/Renderer/UniformState.js @@ -1523,7 +1523,6 @@ function cleanNormal3D(uniformState) { const m = uniformState._normal3D; Matrix4.getMatrix3(uniformState.inverseModelView3D, m); - Matrix3.getRotation(m, m); Matrix3.transpose(m, m); } } From f52a861a94a75ea8f12924a51deba76ee19790e0 Mon Sep 17 00:00:00 2001 From: Jeshurun Hembd Date: Wed, 4 Oct 2023 17:48:59 -0400 Subject: [PATCH 3/5] Fix inverse normal matrices in UniformState --- .../engine/Source/Renderer/UniformState.js | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/packages/engine/Source/Renderer/UniformState.js b/packages/engine/Source/Renderer/UniformState.js index 5b20e9e5c70a..99d7b96570bf 100644 --- a/packages/engine/Source/Renderer/UniformState.js +++ b/packages/engine/Source/Renderer/UniformState.js @@ -1530,28 +1530,20 @@ function cleanNormal3D(uniformState) { function cleanInverseNormal(uniformState) { if (uniformState._inverseNormalDirty) { uniformState._inverseNormalDirty = false; - Matrix4.getMatrix3( - uniformState.inverseModelView, - uniformState._inverseNormal - ); - Matrix3.getRotation( - uniformState._inverseNormal, - uniformState._inverseNormal - ); + + const m = uniformState._inverseNormal; + Matrix4.getMatrix3(uniformState.modelView, m); + Matrix3.transpose(m, m); } } function cleanInverseNormal3D(uniformState) { if (uniformState._inverseNormal3DDirty) { uniformState._inverseNormal3DDirty = false; - Matrix4.getMatrix3( - uniformState.inverseModelView3D, - uniformState._inverseNormal3D - ); - Matrix3.getRotation( - uniformState._inverseNormal3D, - uniformState._inverseNormal3D - ); + + const m = uniformState._inverseNormal3D; + Matrix4.getMatrix3(uniformState.modelView, m); + Matrix3.transpose(m, m); } } From 9dcbc6679bcb53515c1a12237f2696b0e7afe2ec Mon Sep 17 00:00:00 2001 From: Jeshurun Hembd Date: Wed, 4 Oct 2023 17:51:57 -0400 Subject: [PATCH 4/5] Update CHANGES.md --- CHANGES.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 6e07ff5c2ea6..f2cf605b007a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,13 @@ # Change Log +### 1.111 - 2023-11-01 + +#### @cesium/engine + +##### Fixes :wrench: + +- Fixed `czm_normal`, `czm_normal3D`, `czm_inverseNormal`, and `czm_inverseNormal3D` for cases where the model matrix has non-uniform scale. [#11553](https://github.com/CesiumGS/cesium/pull/11553) + ### 1.110 - 2023-10-02 #### @cesium/engine From 9556061261a71137446436323f7baba52cd87176 Mon Sep 17 00:00:00 2001 From: Jeshurun Hembd Date: Wed, 4 Oct 2023 18:13:07 -0400 Subject: [PATCH 5/5] Fix copy-paste error in uniformState.inverseNormal3D --- packages/engine/Source/Renderer/UniformState.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/engine/Source/Renderer/UniformState.js b/packages/engine/Source/Renderer/UniformState.js index 99d7b96570bf..ffe2b972ecaa 100644 --- a/packages/engine/Source/Renderer/UniformState.js +++ b/packages/engine/Source/Renderer/UniformState.js @@ -1542,7 +1542,7 @@ function cleanInverseNormal3D(uniformState) { uniformState._inverseNormal3DDirty = false; const m = uniformState._inverseNormal3D; - Matrix4.getMatrix3(uniformState.modelView, m); + Matrix4.getMatrix3(uniformState.modelView3D, m); Matrix3.transpose(m, m); } }