Browse Source

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.
Olli Etuaho 5 năm trước cách đây
mục cha
commit
677e44e00c
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 2 1
      src/renderers/WebGLRenderer.js

+ 2 - 1
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 ) {