Update - This is outdated. Please use Immersive Environments V2 - Advanced 'Package'-Based Audio and Lighting Control instead. Thank you for the support on this!
I’m releasing a ModuleScript for you all that creates, what I like to call “truly dynamic lighting”! I originally designed it for City of Boston (a project I work on), but I promised a while ago that I would release something like this so here we are!
This is pretty similar (in concept) to A Guide to a Better Looking and More Realistic Day/Night Cycle but I’ve made some changes that I think will benefit developers! Check that link out if you’re having trouble conceptualizing what this does (this pretty much takes the hard work out of doing that and provides advanced customization + features such as weather integration and advanced lighting (or part and light instances) synchronization.
The script is pretty simple: create “Lighting Periods,” specify the beginning and ending times of the Lighting Period, adjust the desired Lighting settings for that period, and let the script take care of the rest!
A few key features of this:
Easy set up
Instructions are provided as code annotations, but I have also rigged several example places on the github page to show the script in action in various scenarios/setups. If there are any questions, my DMs are always open as well.
Compatible with weather scripts
This module is designed to be compatible with weather. You can freely customize the module to create different Lighting effects for different kinds of whether (that way multiple lighting scripts aren’t stepping on each other’s toes)
Specify different lighting periods
When weather is not activated, customize:
- Lighting Period beginning and ending times (ex: dawn, day, twilight, night, etc.)
When weather is activated, customize:
- Blur Size
- SunRays Intensity
If that’s not enough for you, it is very easy to add more settings!
Ability to turn on buildings lights or make glass appear to be lit
I always thought this was a neat effect in games, and essentially this means that you can set certain time periods to turn lights on. An example of this is turning on certain lights when a night time LightingPeriod is active. This can be set up to turn on various lighting instances (PointLight, SpotLight, or SurfaceLight) or parts (such as a window part that you want to seem illuminated (glow effect + color change) by specifying their names. The script will automatically check what type of instance it is and tween the properties of it to your specifications! You can also set up lights to work with weather. This supports randomization to add a touch of realism, because in reality no one turns on all their lights at all times whenever darkness or weather hits. You can specify the percentage chance of something turning out ex: 80, and the module will take care of it all.
One big feature of this is that this Module supports “multi-instance lights” (for lack of a better name). An example of this would be a lantern which has a part that we want to turn neon (to give a lit effect) and a PointLight within it. The module dodges the issue created by randomization that “if each has a 50% chance of turning on, there’s only a 25% chance of them both turning on at the same time” and allows you to indicate multi-instance lights and treat them almost as one entity (while still offering customization controls)
"Smart" set up/compatibility with day night scripts
You do not need to use a “certain” day/night script for this to work in your game.
Furthermore, when specifying Lighting Periods, the script will automatically calculate the rate at which time passes in your game and accordingly starts tweens so that they finish perfectly at the beginning of the Lighting Period. The script will also detect and compensate for any time periods that cross into other dates (ex: starting at night and ending on the “next” day).
List of functions to increase usability. The module works perfectly fine if used on a function-by-function basis
More features and documentation can be found on the github. The github also includes example places that show the module in action and using all of its features. Reference that for help!
The module is also included in the github, but can also be found in the Toolbox
I’ve done my best to effectively and strenuously bug test this, but if there are any bugs, please let me know!! At some point in the future, I’ll look to create a V2 of this with more increasingly advanced features for developers!