TLDR
While the module is simple, it is good for trying to fix the problem with Roblox’s lighting system not including the attenuation function.
It could be used for games such as showcases or horror games so it gives a much more realistic feeling.
It could be improved by using the formula for light attenuation and being more customizable.
Introduction
Sometimes, when you use light sources in your games so they look realistic, you get this weird falloff effect that just rubs you the wrong way. And sometimes, you don't want to make the light fade away the further it travels because it takes too much work.That’s why I’ve made this module script to deal with it, while trying to be as realistic as performant as possible.
Examples (from a testing game)
How to use
This is how you should use the module:- Insert the module and place it onto ReplicatedStorage or ReplicatedFirst.
- Insert a script (server or local) into an instance with a light source (or multiple) inside it.
- Write the script like this:
local module = require(game.ReplicatedStorage.LightFalloff)
module:ApplyFalloff(script.Parent, 0.5) -- 0.5 isn't needed as it's a default number for the intensity.
And boom! You now have a more realistic lighting!
Limitation
While the module is simple to use, it doesn't have as much customizability and can probably cause several artifacts to appear since Roblox isn't designed to handle that much lighting if used on at least ten instances with light sources inside them.You cannot adjust the falloff effect without having to edit the module itself, which can be inconvenient since there are games that want style and not realism.
The module doesn’t use the formula for light attenuation, instead it uses (n - i) x intensity to simulate light attenuation, which can be unrealistic at times.