Browse Source

Merge pull request #5036 from NVIDIA/optimize-uniforms-list

Only put those uniforms to uniformsList which are in the program
Mr.doob 11 years ago
parent
commit
242e95108e
1 changed files with 8 additions and 6 deletions
  1. 8 6
      src/renderers/WebGLRenderer.js

+ 8 - 6
src/renderers/WebGLRenderer.js

@@ -4256,7 +4256,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		for ( u in material.__webglShader.uniforms ) {
 
-			material.uniformsList.push( [ material.__webglShader.uniforms[ u ], u ] );
+			var location = material.program.uniforms[ u ];
+
+			if ( location ) {
+				material.uniformsList.push( [ material.__webglShader.uniforms[ u ], location ] );
+			}
 
 		}
 
@@ -4470,7 +4474,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			// load common uniforms
 
-			loadUniformsGeneric( program, material.uniformsList );
+			loadUniformsGeneric( material.uniformsList );
 
 		}
 
@@ -4758,15 +4762,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function loadUniformsGeneric ( program, uniforms ) {
+	function loadUniformsGeneric ( uniforms ) {
 
 		var texture, textureUnit, offset;
 
 		for ( var j = 0, jl = uniforms.length; j < jl; j ++ ) {
 
-			var location = program.uniforms[ uniforms[ j ][ 1 ] ];
-
-			if ( ! location ) continue;
+			var location = uniforms[ j ][ 1 ];
 
 			var uniform = uniforms[ j ][ 0 ];