diff --git a/source/Renderer/renderer.js b/source/Renderer/renderer.js index 5ea8b213..3a19687e 100644 --- a/source/Renderer/renderer.js +++ b/source/Renderer/renderer.js @@ -1139,11 +1139,15 @@ class gltfRenderer { } const worldTransform = node.getRenderedWorldTransform(); + + const normalMatrix = mat4.create(); + mat4.invert(normalMatrix, node.getRenderedWorldTransform()); + mat4.transpose(normalMatrix, normalMatrix); // update model dependant matrices once per node this.shader.updateUniform("u_ViewProjectionMatrix", viewProjectionMatrix); this.shader.updateUniform("u_ModelMatrix", worldTransform); - this.shader.updateUniform("u_NormalMatrix", node.normalMatrix, false); + this.shader.updateUniform("u_NormalMatrix", normalMatrix, false); this.shader.updateUniform("u_Exposure", state.renderingParameters.exposure, false); this.shader.updateUniform("u_Camera", this.currentCameraPosition, false); if (renderpassConfiguration.picking) { diff --git a/source/gltf/node.js b/source/gltf/node.js index 764e13b7..c0637c91 100644 --- a/source/gltf/node.js +++ b/source/gltf/node.js @@ -29,7 +29,6 @@ class gltfNode extends GltfObject { this.worldQuaternion = quat.create(); this.worldScale = vec3.create(); this.inverseWorldTransform = mat4.create(); - this.normalMatrix = mat4.create(); this.light = undefined; this.instanceMatrices = undefined; this.instanceWorldTransforms = undefined; diff --git a/source/gltf/scene.js b/source/gltf/scene.js index 75fccfc7..14763b88 100644 --- a/source/gltf/scene.js +++ b/source/gltf/scene.js @@ -29,7 +29,6 @@ class gltfScene extends GltfObject { if (nodeDirty) { mat4.multiply(node.worldTransform, parentTransform, node.getLocalTransform()); mat4.invert(node.inverseWorldTransform, node.worldTransform); - mat4.transpose(node.normalMatrix, node.inverseWorldTransform); quat.multiply(node.worldQuaternion, parentRotation, node.rotation); mat4.getScaling(node.worldScale, node.worldTransform); if (parentScaleDirty || node.animatedPropertyObjects["scale"].dirty) {