"Truly Dynamic Lighting" Module (Advanced Lighting Capabilities and Control)

Update - This is outdated. Please use Immersive Environments - Advanced Audio and Lighting Control instead. Thank you for the support on this!

Hey Developers!

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)

Advanced customization

Specify different lighting periods
When weather is not activated, customize:

  • Lighting Period beginning and ending times (ex: dawn, day, twilight, night, etc.)
  • Ambient
  • ShadowSoftness
  • OutdoorAmbient
  • ShadowSoftness

When weather is activated, customize:

  • Blur Size
  • SunRays Intensity
  • FogColor
  • FogEnd
  • Brightness
  • Ambient
  • OutdoorAmbient
  • ShadowSoftness
  • ShadowSoftness
  • WaterReflectance
  • WaterWaveSpeed
  • WaterWaveSize

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).

ModuleScript

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!

52 Likes

Nice, this looks really interesting, smoothly changing the lighting could really make a difference. Congrats.

1 Like

Does this module support arbitrarily changing the ClockTime/TimeOfDay (for example, using an admin command to set the time to midnight)?

Yes, if an admin arbitrarily changes the ClockTime/TimeOfDay the module will begin automatically tweening the lighting properties to whatever Lighting Period you’ve changed it to. So, if time was 06:00 and an admin changes the time to 23:00 and you have a Lighting Period set up that encloses the 23:00 time frame, the module will begin tweening the lighting settings to that period.

You can also use the function SetLighting immediately after calling the admin command if you want the Lighting Settings to immediately take effect.

1 Like

And can this run standalone with just a script calling the function?

1 Like

Yes, this can be called with just one line module.DynamicLightingSystem(). All other configurations (specifying the Lighting Periods and the various lighting settings, etc.) take place within the Module itself at the top.

2 Likes

Can you please show some screenshots or video clips?

This module is outdated. The successor is Immersive Environments - Advanced Audio and Lighting Control.

There’s an example place there to play around in with dramatized settings (for Immersive Environments, not Truly Dynamic Lighting). Here’s a video of Truly Dynamic Lighting, though, in action in another development project:

Quality isn’t great, but especially at points like dusk, night, midnight, and dawn, it does a good job of showing why non-uniform lighting can hugely enhance the immersion levels of your game.

The updated module (Immersive Environments) is more efficient and allows developers to handle lighting better (including ‘complex instances’), have audio control w/ advanced customization, and adjust lighting/audio by region (ex: going into a building which might have it’s own unique lighting).

I am currently working on a update which will integrate region specific time-based controls. However, the existing module is still plenty powerful.

1 Like