Selaa lähdekoodia

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 vuotta sitten
vanhempi
commit
677e44e00c
1 muutettua tiedostoa jossa 2 lisäystä ja 1 poistoa
  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 ) {