From bb960c66f63dbf65d41cb54ded64b67c411d9b1f Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Mon, 2 Nov 2015 12:51:41 -0500 Subject: [PATCH] add back spot light cutoff. --- .../shaders/ShaderChunk/lights_pars.glsl | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/renderers/shaders/ShaderChunk/lights_pars.glsl b/src/renderers/shaders/ShaderChunk/lights_pars.glsl index 3ea0adea11e235..4e9615a2706603 100644 --- a/src/renderers/shaders/ShaderChunk/lights_pars.glsl +++ b/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