From 180f4ba4f509e2c70d6f86905d5e4c49ecd704c9 Mon Sep 17 00:00:00 2001 From: Geenz Date: Sun, 22 May 2016 21:02:28 -0400 Subject: [PATCH] Tweaked light attenuation formula some more. Keeping the ulightvec parameter for now - I want to revisit this later. --- libraries/model/src/model/Light.slh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/model/src/model/Light.slh b/libraries/model/src/model/Light.slh index 46eb352d16..de15e50908 100644 --- a/libraries/model/src/model/Light.slh +++ b/libraries/model/src/model/Light.slh @@ -106,9 +106,11 @@ float evalLightAttenuation(Light l, float d, vec3 ulightvec) { float denom = d / radius + 1.0; float attenuation = 1.0 / (denom * denom); + float cutoff = getLightCutoffRadius(l); + // "Fade" the edges of light sources to make things look a bit more attractive. // Note: this tends to look a bit odd at lower exponents. - attenuation *= clamp(0, 1, mix(0, 1, getLightCutoffSquareRadius(l) - dot(ulightvec, ulightvec))); + attenuation *= min(1, max(0, -(d - cutoff))); return attenuation; }