diff --git a/src/engine.cpp b/src/engine.cpp index 17e12785..6663e2bf 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -39,8 +39,15 @@ float Light::getBrightness() { } void Light::setBrightnessSmooth(float brightness) { - // lambda = 3 * framerate - value += (brightness * brightness - value) * sampleTime * (60.0 * 3.0); + float v = brightness * brightness; + if (v < value) { + // Fade out light with lambda = 3 * framerate + value += (v - value) * sampleTime * (60.0 * 3.0); + } + else { + // Immediately illuminate light + value = v; + } }