Browse Source

Merge remote-tracking branch 'alteredq/dev' into dev

Mr.doob 13 years ago
parent
commit
1ef3d27522
4 changed files with 119 additions and 139 deletions
  1. 58 58
      build/Three.js
  2. 32 32
      build/custom/ThreeWebGL.js
  3. 8 18
      src/renderers/WebGLRenderer.js
  4. 21 31
      src/renderers/WebGLShaders.js

File diff suppressed because it is too large
+ 58 - 58
build/Three.js


File diff suppressed because it is too large
+ 32 - 32
build/custom/ThreeWebGL.js


+ 8 - 18
src/renderers/WebGLRenderer.js

@@ -2214,20 +2214,19 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 						for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
 						for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
 
 
-							value = customAttribute.value[ offset_customSrc ];
+							value = customAttribute.value[ chunk_faces3[ f ] ];
 
 
 							customAttribute.array[ offset_custom ] 	   = value;
 							customAttribute.array[ offset_custom ] 	   = value;
 							customAttribute.array[ offset_custom + 1 ] = value;
 							customAttribute.array[ offset_custom + 1 ] = value;
 							customAttribute.array[ offset_custom + 2 ] = value;
 							customAttribute.array[ offset_custom + 2 ] = value;
 
 
 							offset_custom += 3;
 							offset_custom += 3;
-							offset_customSrc += 1;
 
 
 						}
 						}
 
 
 						for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
 						for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
 
 
-							value = customAttribute.value[ offset_customSrc ];
+							value = customAttribute.value[ chunk_faces4[ f ] ];
 
 
 							customAttribute.array[ offset_custom ] 	   = value;
 							customAttribute.array[ offset_custom ] 	   = value;
 							customAttribute.array[ offset_custom + 1 ] = value;
 							customAttribute.array[ offset_custom + 1 ] = value;
@@ -2235,7 +2234,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 							customAttribute.array[ offset_custom + 3 ] = value;
 							customAttribute.array[ offset_custom + 3 ] = value;
 
 
 							offset_custom += 4;
 							offset_custom += 4;
-							offset_customSrc += 1;
 
 
 						}
 						}
 
 
@@ -2320,7 +2318,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 						for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
 						for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
 
 
-							value = customAttribute.value[ offset_customSrc ];
+							value = customAttribute.value[ chunk_faces3[ f ] ];
 
 
 							v1 = value;
 							v1 = value;
 							v2 = value;
 							v2 = value;
@@ -2336,13 +2334,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 							customAttribute.array[ offset_custom + 5 ] = v3.y;
 							customAttribute.array[ offset_custom + 5 ] = v3.y;
 
 
 							offset_custom += 6;
 							offset_custom += 6;
-							offset_customSrc += 1;
 
 
 						}
 						}
 
 
 						for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
 						for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
 
 
-							value = customAttribute.value[ offset_customSrc ];
+							value = customAttribute.value[ chunk_faces4[ f ] ];
 
 
 							v1 = value;
 							v1 = value;
 							v2 = value;
 							v2 = value;
@@ -2362,7 +2359,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 							customAttribute.array[ offset_custom + 7 ] = v4.y;
 							customAttribute.array[ offset_custom + 7 ] = v4.y;
 
 
 							offset_custom += 8;
 							offset_custom += 8;
-							offset_customSrc += 1;
 
 
 						}
 						}
 
 
@@ -2480,7 +2476,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 							customAttribute.array[ offset_custom + 11 ] = v4[ pp[ 2 ] ];
 							customAttribute.array[ offset_custom + 11 ] = v4[ pp[ 2 ] ];
 
 
 							offset_custom += 12;
 							offset_custom += 12;
-							offset_customSrc += 1;
 
 
 						}
 						}
 
 
@@ -2488,7 +2483,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 						for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
 						for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
 
 
-							value = customAttribute.value[ offset_customSrc ];
+							value = customAttribute.value[ chunk_faces3[ f ] ];
 
 
 							v1 = value;
 							v1 = value;
 							v2 = value;
 							v2 = value;
@@ -2507,13 +2502,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 							customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];
 							customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];
 
 
 							offset_custom += 9;
 							offset_custom += 9;
-							offset_customSrc += 1;
 
 
 						}
 						}
 
 
 						for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
 						for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
 
 
-							value = customAttribute.value[ offset_customSrc ];
+							value = customAttribute.value[ chunk_faces4[ f ] ];
 
 
 							v1 = value;
 							v1 = value;
 							v2 = value;
 							v2 = value;
@@ -2537,7 +2531,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 							customAttribute.array[ offset_custom + 11 ] = v4[ pp[ 2 ] ];
 							customAttribute.array[ offset_custom + 11 ] = v4[ pp[ 2 ] ];
 
 
 							offset_custom += 12;
 							offset_custom += 12;
-							offset_customSrc += 1;
 
 
 						}
 						}
 
 
@@ -2664,7 +2657,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 						for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
 						for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
 
 
-							value = customAttribute.value[ offset_customSrc ];
+							value = customAttribute.value[ chunk_faces3[ f ] ];
 
 
 							v1 = value;
 							v1 = value;
 							v2 = value;
 							v2 = value;
@@ -2686,13 +2679,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 							customAttribute.array[ offset_custom + 11 ] = v3.w;
 							customAttribute.array[ offset_custom + 11 ] = v3.w;
 
 
 							offset_custom += 12;
 							offset_custom += 12;
-							offset_customSrc += 1;
 
 
 						}
 						}
 
 
 						for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
 						for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
 
 
-							value = customAttribute.value[ offset_customSrc ];
+							value = customAttribute.value[ chunk_faces4[ f ] ];
 
 
 							v1 = value;
 							v1 = value;
 							v2 = value;
 							v2 = value;
@@ -2720,7 +2712,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 							customAttribute.array[ offset_custom + 15 ] = v4.w;
 							customAttribute.array[ offset_custom + 15 ] = v4.w;
 
 
 							offset_custom += 16;
 							offset_custom += 16;
-							offset_customSrc += 1;
 
 
 						}
 						}
 
 
@@ -4836,7 +4827,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	function refreshUniformsLights ( uniforms, lights ) {
 	function refreshUniformsLights ( uniforms, lights ) {
 
 
-		uniforms.enableLighting.value = lights.directional.length + lights.point.length;
 		uniforms.ambientLightColor.value = lights.ambient;
 		uniforms.ambientLightColor.value = lights.ambient;
 
 
 		uniforms.directionalLightColor.value = lights.directional.colors;
 		uniforms.directionalLightColor.value = lights.directional.colors;

+ 21 - 31
src/renderers/WebGLShaders.js

@@ -258,7 +258,6 @@ THREE.ShaderChunk = {
 		"uniform vec3 ambient;",
 		"uniform vec3 ambient;",
 		"uniform vec3 diffuse;",
 		"uniform vec3 diffuse;",
 
 
-		"uniform bool enableLighting;",
 		"uniform vec3 ambientLightColor;",
 		"uniform vec3 ambientLightColor;",
 
 
 		"#if MAX_DIR_LIGHTS > 0",
 		"#if MAX_DIR_LIGHTS > 0",
@@ -280,51 +279,43 @@ THREE.ShaderChunk = {
 
 
 	lights_lambert_vertex: [
 	lights_lambert_vertex: [
 
 
-		"if ( !enableLighting ) {",
+		"vLightWeighting = vec3( 0.0 );",
 
 
-			"vLightWeighting = vec3( 1.0 );",
-
-		"} else {",
-
-			"vLightWeighting = vec3( 0.0 );",
-
-			"#if MAX_DIR_LIGHTS > 0",
-
-			"for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {",
+		"#if MAX_DIR_LIGHTS > 0",
 
 
-				"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );",
-				"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );",
-				"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;",
+		"for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {",
 
 
-			"}",
+			"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );",
+			"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );",
+			"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;",
 
 
-			"#endif",
+		"}",
 
 
-			"#if MAX_POINT_LIGHTS > 0",
+		"#endif",
 
 
-				"for( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {",
+		"#if MAX_POINT_LIGHTS > 0",
 
 
-					"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );",
+			"for( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {",
 
 
-					"vec3 lVector = lPosition.xyz - mvPosition.xyz;",
+				"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );",
 
 
-					"float lDistance = 1.0;",
+				"vec3 lVector = lPosition.xyz - mvPosition.xyz;",
 
 
-					"if ( pointLightDistance[ i ] > 0.0 )",
-						"lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );",
+				"float lDistance = 1.0;",
 
 
-					"lVector = normalize( lVector );",
+				"if ( pointLightDistance[ i ] > 0.0 )",
+					"lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );",
 
 
-					"float pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );",
-					"vLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;",
+				"lVector = normalize( lVector );",
 
 
-				"}",
+				"float pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );",
+				"vLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;",
 
 
-			"#endif",
+			"}",
 
 
-			"vLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;",
+		"#endif",
 
 
-		"}"
+		"vLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;",
 
 
 	].join("\n"),
 	].join("\n"),
 
 
@@ -937,7 +928,6 @@ THREE.UniformsLib = {
 
 
 	lights: {
 	lights: {
 
 
-		"enableLighting" : { type: "i", value: 1 },
 		"ambientLightColor" : { type: "fv", value: [] },
 		"ambientLightColor" : { type: "fv", value: [] },
 		"directionalLightDirection" : { type: "fv", value: [] },
 		"directionalLightDirection" : { type: "fv", value: [] },
 		"directionalLightColor" : { type: "fv", value: [] },
 		"directionalLightColor" : { type: "fv", value: [] },

Some files were not shown because too many files changed in this diff