From 076c984c438bea2b34f8dd3a62bb31ebd2eb5282 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Fri, 10 Jun 2016 15:33:02 -0400 Subject: actual game making --- shaders/world.frag | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'shaders') diff --git a/shaders/world.frag b/shaders/world.frag index bde5fa5..617cbb1 100644 --- a/shaders/world.frag +++ b/shaders/world.frag @@ -23,10 +23,12 @@ void main() for (int i = 0; i < lightSize; i++) { vec2 loc = light[i].xy; float dist = length(loc - fragCoord.xy); - float attenuation = clamp(1.0f - dist*dist/(light[i].w*light[i].w), 0.0f, 1.0f); - attenuation *= attenuation; + if (dist < light[i].w) { + float attenuation = clamp(1.0f - dist*dist/(light[i].w*light[i].w), 0.0f, 1.0f); + attenuation *= attenuation; - shadeColor += (vec4(attenuation, attenuation, attenuation, 0.0f) * vec4(lightColor[i])) * lightImpact; + shadeColor += (vec4(attenuation, attenuation, attenuation, 0.0f) * vec4(lightColor[i])) * lightImpact; + } } } shadeColor += ambientLight; -- cgit v1.2.3