From 677e44e00cc37cce22d7b2cbe03db296d03666d5 Mon Sep 17 00:00:00 2001 From: Olli Etuaho Date: Fri, 3 Apr 2020 17:20:37 +0300 Subject: [PATCH] Update materialProperties.environment even if program doesn't change The environment map can be switched to a different image while still using the exact same shader. It's important to update materialProperties.environment in this case so that unnecessary calls to initMaterial can be avoided. Prior to this fix FPS could be halved after changing scene.environment. --- src/renderers/WebGLRenderer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index ee26d7370a34f5..e6e303cb2ec803 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -1519,12 +1519,13 @@ function WebGLRenderer( parameters ) { materialProperties.program = program; materialProperties.uniforms = parameters.uniforms; - materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null; materialProperties.outputEncoding = _this.outputEncoding; material.program = program; } + materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null; + var programAttributes = program.getAttributes(); if ( material.morphTargets ) {