[V2] Sunray Intensity Compensation System

Hey! This is my SIC System :sunglasses: An ongoing project I’ve been working on that adds a bit of a unique feel of immersion to your experience! Allow me to introduce you to the second version my Sunray Intensity Compensation System!

This system tweaks a SunRaysEffect instance to a specific value every time the camera moves. If the camera is looking closer towards the sun than the previous check, then sunray intensity will be decreased.

The closer you look towards the sun, the less intense sunrays are. This eliminates the issues with high intensity values, while maintaining 99% of control over the sun, sky, clouds, and anything else.

As of May 10th, 2023, I have updated the script to version 2.0.0

The script can be found through the link located in the Script dropdown section below.

Check the Changelog section below for new changes; I will continue to keep this updated.

•Put in ServerScriptService
•Edit any necessary settings that you’d like in the SunrayIntensityController.Settings module and the SunrayIntensityController.Presets module

If there are any better ways to code sections of this script or the entirety of it, do feel free to post a comment. I will gladly adjust the script to add the necessary changes and give credit where credit is due.

This also applies to bugs and any instances of lag being caused by this script. Please let me know if you encounter either of these!


Notes

•In the beginning of March (2023), I created version 1.0. This version will always be available. However, due to the massive changes this version made to the system, I decided to keep version 1.0 around but I won’t be updating it. With the exception of bug fixes.

-The DevForum post for version 1.0 can be found here:
[Lighting] Sunray Intensity Compensation

Showcase

Test Experience, free to test!
Sunray Intensity Compensation System V2 - Roblox

Showcase Video
Excuse the UI designs I used, I was testing out UI stuff I don’t typically play with… I’m also not a UI designer.
Roblox Sunray Intensity Compensation System Showcase - YouTube

Script

[V2] Sunray Intensity Compensation System - Roblox


Changelog

Version 2.0.0

•Moved ~98% of the main code to separated functions when running the Runservice.Heartbeat:Connect() function

•Tweaked much of the math involved to calculate intensity; resulting in a much needed spike in accuracy when taking new sun sizes into account (as well as just around the forgiveness radius border & the outer ring of the Sun/SunRaysEffect)

•Added backup API functions to call for updating the Forgiveness, allowing developers to add triggers to their games that can update the sun size if the system fails to recognize an update to Sky.SunAngularSize

*You can find the API functions in the new ‘ReadMe’ folder and in the DevForum post for this system

•Increased NearSunRays’ intensity from 0.06 to 0.085 for increased immersion. I felt 0.06 didn’t make a good enough impression for default

•Added support for terrain blocking the sun

•Added ‘Instant’ Preset for instant changes to intensity

•New location for the system is ServerScriptService instead of StarterPlayerScripts
-The localscript (main functioning part of the system) is inserted into any joining players’ PlayerGui folder
-This is because I have to require a module by AssetId; which is only able to be done by server-scripts. Server scripts don’t have access to Player.PlayerScripts
-The system will automatically change the .Parent property of the main localscript to Players.LocalPlayer.PlayerScripts (as if the script was originally in StarterPlayerScripts)

•Added update notification support! Check the Output window when you begin a play-test session for information about your version of this system as well as the latest release version!

•Separated the function that actually changed the intensity value of FarSunRays; this was easier for me to compress code down and incorperate the ‘instant’ preset

•Moved the ‘Custom’ preset TweenInfo() table from the ‘Settings’ ModuleScript to the ‘Presets’ ModuleScript

•You can now update the preset currently being used by the system by requiring the ‘Settings’ module and using SettingsModuleName.SetActivePreset("PresetNameHere")

•Added optional API for changing to a “night” time while keeping active sunrays (See API for more details)

•The script now comes with 2 custom Sky instances in the Settings modulescript. These are inserted and switched for different time modes (See API for more details)

•Added API function for getting the current sky (See API for more details)

•Added API function for updating the forgiveness value. (See API for more details)

API

API

𝗦𝘂𝗻𝗿𝗮𝘆𝗖𝗼𝗻𝗳𝗶𝗴.𝗦𝗲𝘁𝗔𝗰𝘁𝗶𝘃𝗲𝗣𝗿𝗲𝘀𝗲𝘁("𝗣𝗿𝗲𝘀𝗲𝘁𝗡𝗮𝗺𝗲") : ()
→ Update the current preset being used
-Examples: You may want to switch presets for cutscenes, mass camera-shake, explosions, etc. - Does not return anything
— Example Code: ‘SunrayConfig.SetActivePreset(“Cinematic”)’ …inside a .Touched event for a cutscene trigger or prompt on a door.

𝗦𝘂𝗻𝗿𝗮𝘆𝗖𝗼𝗻𝗳𝗶𝗴.𝗨𝗽𝗱𝗮𝘁𝗲𝗙𝗼𝗿𝗴𝗶𝘃𝗲𝗻𝗲𝘀𝘀(𝗻𝗲𝘄𝗙𝗼𝗿𝗴𝗶𝘃𝗲𝗻𝗲𝘀𝘀𝗡𝘂𝗺𝗯𝗲𝗿𝗩𝗮𝗹𝘂𝗲) : ()
→ Update the Forgiveness in the Settings ModuleScript to the passed newForgivenessNumberValue. This is used in the main localscript and passes Lighting.Sky.SunAngularSize as the new forgiveness value. Therefore, any changes to sun size are taken into account with this system and sunrays now alter intensity to fit the new forgiveness radius. There is a GetPropertyChangedSignal() function in the main script that calls this function; so it is not usually necessary to use it. You just have to change SunAngularSize.

𝗦𝘂𝗻𝗿𝗮𝘆𝗖𝗼𝗻𝗳𝗶𝗴.𝗚𝗲𝘁𝗦𝗸𝘆() : Instance
→ This will return the current Sky being used. At this moment, sky’s are stored inside of the settings module and are switched out if night mode is ever activated.

𝗠𝗮𝗶𝗻𝗖𝗼𝗻𝗳𝗶𝗴.𝘂𝗽𝗱𝗮𝘁𝗲𝗡𝗶𝗴𝗵𝘁𝗦𝘁𝗮𝘁𝘂𝘀(𝗶𝘀𝗡𝗶𝗴𝗵𝘁) : ()
→ This function enables/disables Night Mode. When activated,
The time of day spans quickly through a single night into the next morning. However, halfway through the change,
the custom Sky that is in the Settings module is replaced with the current CustomDaySky in game.Lighting.
-The CustomDaySky’s Moon is disabled to not show its moon during the transition.
-After the “fake night” sky has been applied, the sun texture is replaced with a moon, and it is still daytime. Just with a night-time skybox
and a moon texture for the sun. This gives the impression of ‘moon rays’.

4 Likes

Could you please open source the test place.
You could remove the afk gui, and donate gui though

Hello! Sorry for the slightly late reply. The AFK gui and donation zzzzGui don’t worry me. It’s the feedback gui I setup that has a Discord webhook URL. And should that webhook URL get into ill-minded hands, my Discord server can be blown up repeatedly with unwanted messages.

As I’m writing this, I’ve come up with a new idea. I’ve removed the FeedbackGui from the main testing place and added it to a copylocked sub-place. Everything is 100% identical, minus the feedback gui.

The main test place is now uncopylocked :smiley:

Alright thank you
And make sure to use the 1k dono from yesterday to good use :wink:

1 Like

I didn’t realize you donated! Thank you so much!

You’ve my word it will go to great use :slight_smile: