Rust like nighttime
2020 I played a lot of Rust and one of the things about the game that stands out for a lot of people is just how dark the nighttime is in the game. Sometimes engaging in a bow fight being able to only see a silhouette. I wanted to create a similar effect in UE4.
First I knew I needed to manually drop the ambient occlusion across all the materials used for surfaces in the game. To do this I created a Material Parameter Collection called GlobalMaterialSettings.
This collection will house all the global material settings to make this transition go smoothly. There are some other effects that will need to be tweaked like the subsurface scattering values of foliage’s materials.
As a quick workaround, I check if the ambient occlusion is greater than 0, then use the intended subsurface color. If the AO is equal to or greater than 0, set the subsurface value to 0. It’s a simple way to get around it for now.
In most other surface cases you can either just use this value directly as the Ambient Occlusion, or multiply it by the AO map.
I created an Actor called GlobalSettings that will manipulate these settings so that they are all in one place and can be replicated more easily down the road. In it’s EventGraph, I set up a timer to more easily adjust the rate and whether it cycles at all for testing. I also create variables to hold the light source that we’ll rotate (sun) and the base Sky Sphere included in the engine content for now.
Each time the event is fired off, I also want to call the UpdateSunDirection on the SkySphere.
Next if the Directional Light’s light component (sun) has a Y pitch rotation above 0 we want to set the AO to 0. This could be interpolated between 1 and 0 to get a smoother transition. I’m also using a volumetric height fog during the day and don’t wish it to effect the night lighting so I toggle it’s visibility. There are other better ways to do this but I just wanted to test it.
So there you have it, the start of a Rusty night.