Browse Source

WebGLRenderer: Avoid unneeded uniform updates per ArrayCamera's sub-camera

Mr.doob 8 years ago
parent
commit
aed9f30541
1 changed files with 9 additions and 2 deletions
  1. 9 2
      src/renderers/WebGLRenderer.js

+ 9 - 2
src/renderers/WebGLRenderer.js

@@ -124,7 +124,9 @@ function WebGLRenderer( parameters ) {
 		_currentFramebuffer = null,
 		_currentFramebuffer = null,
 		_currentMaterialId = - 1,
 		_currentMaterialId = - 1,
 		_currentGeometryProgram = '',
 		_currentGeometryProgram = '',
+
 		_currentCamera = null,
 		_currentCamera = null,
+		_currentArrayCamera = null,
 
 
 		_currentScissor = new Vector4(),
 		_currentScissor = new Vector4(),
 		_currentScissorTest = null,
 		_currentScissorTest = null,
@@ -1476,6 +1478,8 @@ function WebGLRenderer( parameters ) {
 
 
 			if ( camera.isArrayCamera ) {
 			if ( camera.isArrayCamera ) {
 
 
+				_currentArrayCamera = camera;
+
 				var cameras = camera.cameras;
 				var cameras = camera.cameras;
 
 
 				for ( var j = 0, jl = cameras.length; j < jl; j ++ ) {
 				for ( var j = 0, jl = cameras.length; j < jl; j ++ ) {
@@ -1498,6 +1502,8 @@ function WebGLRenderer( parameters ) {
 
 
 			} else {
 			} else {
 
 
+				_currentArrayCamera = null;
+
 				renderObject( object, scene, camera, geometry, material, group );
 				renderObject( object, scene, camera, geometry, material, group );
 
 
 			}
 			}
@@ -1775,10 +1781,11 @@ function WebGLRenderer( parameters ) {
 
 
 			}
 			}
 
 
+			// Avoid unneeded uniform updates per ArrayCamera's sub-camera
 
 
-			if ( camera !== _currentCamera ) {
+			if ( _currentCamera !== ( _currentArrayCamera || camera ) ) {
 
 
-				_currentCamera = camera;
+				_currentCamera = ( _currentArrayCamera || camera );
 
 
 				// lighting uniforms depend on the camera so enforce an update
 				// lighting uniforms depend on the camera so enforce an update
 				// now, in case this material supports lights - or later, when
 				// now, in case this material supports lights - or later, when