瀏覽代碼

automatic detection of dynamic uniforms

arose 9 年之前
父節點
當前提交
7b9721cb81
共有 2 個文件被更改,包括 18 次插入3 次删除
  1. 0 2
      examples/webgl_interactive_instances_gpu.html
  2. 18 1
      src/renderers/WebGLRenderer.js

+ 0 - 2
examples/webgl_interactive_instances_gpu.html

@@ -518,7 +518,6 @@
 					}
 				}
 			} );
-			material.hasDynamicUniforms = true;
 			materialList.push( material );
 
 			var pickingMaterial = new THREE.RawShaderMaterial( {
@@ -534,7 +533,6 @@
 					}
 				}
 			} );
-			pickingMaterial.hasDynamicUniforms = true;
 			materialList.push( pickingMaterial );
 
 			// geometry / mesh

+ 18 - 1
src/renderers/WebGLRenderer.js

@@ -1523,6 +1523,23 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
+		// detect dynamic uniforms
+
+		materialProperties.hasDynamicUniforms = false;
+
+		for ( var j = 0, jl = materialProperties.uniformsList.length; j < jl; j ++ ) {
+
+			var uniform = materialProperties.uniformsList[ j ][ 0 ];
+
+			if( typeof uniform.updateFunction === "function" ){
+
+				materialProperties.hasDynamicUniforms = true;
+				break;
+
+			}
+
+		}
+
 	}
 
 	function setMaterial( material ) {
@@ -1814,7 +1831,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
-		if( material.hasDynamicUniforms === true ){
+		if( materialProperties.hasDynamicUniforms === true ){
 
 			updateDynamicUniforms( materialProperties.uniformsList, camera, object );