diff --git a/src/renderers/shaders/ShaderChunk/lights_pars.glsl b/src/renderers/shaders/ShaderChunk/lights_pars.glsl index 9697bd50b0585f..b4e1c7957f0280 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