Browse Source

add back spot light cutoff.

Ben Houston 9 years ago
parent
commit
bb960c66f6
1 changed files with 16 additions and 5 deletions
  1. 16 5
      src/renderers/shaders/ShaderChunk/lights_pars.glsl

+ 16 - 5
src/renderers/shaders/ShaderChunk/lights_pars.glsl

@@ -71,13 +71,24 @@ uniform vec3 ambientLightColor;
 		vec3 lVector = spotLight.position - geometry.position;
 		directLight.direction = normalize( lVector );
 	
-		float spotEffect = dot( spotLight.direction, directLight.direction );
-		spotEffect = saturate( pow( saturate( spotEffect ), spotLight.exponent ) );
-	
-		directLight.color = spotLight.color;
-		directLight.color *= ( spotEffect * calcLightAttenuation( length( lVector ), spotLight.distance, spotLight.decay ) );
+		float spotEffect = dot( directLight.direction, spotLight.direction );
+
+		if ( spotEffect > spotLight.angleCos ) {
+
+			float spotEffect = dot( spotLight.direction, directLight.direction );
+			spotEffect = saturate( pow( saturate( spotEffect ), spotLight.exponent ) );
+		
+			directLight.color = spotLight.color;
+			directLight.color *= ( spotEffect * calcLightAttenuation( length( lVector ), spotLight.distance, spotLight.decay ) );
+
+		}
+		else {
+
+			directLight.color = vec3( 0.0 );
+		}
 
 		return directLight;
+
 	}
 
 #endif