Browse Source

Removed enableLighting uniform from Lambert.

alteredq 13 years ago
parent
commit
99f00ba33e
4 changed files with 25 additions and 36 deletions
  1. 2 2
      build/Three.js
  2. 2 2
      build/custom/ThreeWebGL.js
  3. 0 1
      src/renderers/WebGLRenderer.js
  4. 21 31
      src/renderers/WebGLShaders.js

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


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


+ 0 - 1
src/renderers/WebGLRenderer.js

@@ -4827,7 +4827,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	function refreshUniformsLights ( uniforms, lights ) {
 
-		uniforms.enableLighting.value = lights.directional.length + lights.point.length;
 		uniforms.ambientLightColor.value = lights.ambient;
 
 		uniforms.directionalLightColor.value = lights.directional.colors;

+ 21 - 31
src/renderers/WebGLShaders.js

@@ -258,7 +258,6 @@ THREE.ShaderChunk = {
 		"uniform vec3 ambient;",
 		"uniform vec3 diffuse;",
 
-		"uniform bool enableLighting;",
 		"uniform vec3 ambientLightColor;",
 
 		"#if MAX_DIR_LIGHTS > 0",
@@ -280,51 +279,43 @@ THREE.ShaderChunk = {
 
 	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"),
 
@@ -937,7 +928,6 @@ THREE.UniformsLib = {
 
 	lights: {
 
-		"enableLighting" : { type: "i", value: 1 },
 		"ambientLightColor" : { type: "fv", value: [] },
 		"directionalLightDirection" : { type: "fv", value: [] },
 		"directionalLightColor" : { type: "fv", value: [] },

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