Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Now we are ready to start creating our day-night cycle.


Setting up the Sun

The Sun category contains the settings that affect the color and the intensity of the direct sun light.

Sun Color :

We start off by setting the current time to 12:00 and giving it a slightly yellow tint ( 240, 225, 210 ). This will create a key at that time and update the preview to represent the change we just made. Select the newly created key and set the In/Out tangent to linear.


Pic 4: Screenshot of the Sun Color gradient preview and curves.

Sun intensity ( lux ) :

This property controls the illuminance of the sun and as mentioned previously it is important to keep this close to the physically based value. A quick search on the internet comes up with an average illuminance value of 100000 lux for bright sunlight.


Pic 6: Screenshot of the Sun Intensity (lux) gradient preview and curves.

Sun Specular multiplier :

As you might have guessed this controls the specular contribution of the sunlight. For any realistic lighting scenario this value should always be kept at 1.


Sky Light

You’re probably wondering why we skipped all the way to sky light. The reason is a lot of the settings in the environment editor affect each other. It’s good practice to get the sun/sky settings nailed down before you go into setting up your fog.

Parameters in this section are solely used to compute the sun light scattering through the atmosphere effectively controlling the appearance of the sun disk as well as the hue of your sky. They do not directly affect the rendering of objects in the world (for example, lighting colors and intensities). They do however affect the overall illuminance of your scene through the use of Environment Probes as mentioned earlier.

Sun Intensity Multiplier

Change the time to 12:00 and set the intensity to 50. At 05:45 and 18:15 drop this value to 1. Create two more keys at 00:00 and 23:59 and set the value to 0. The transition from 0 to 1 gives us the effect of the sky brightening  in the area where the sun is just about to set.

Pic 7: Sun Intensity Multiplier curve setup.

Image Added

Pic 8: Screenshot taken at 05:30. Notice the slight brightening of the horizon around the area where the sun is about to rise.

To get an accurate reading of the illuminance in your level you need to measure it on a surface that’s perpendicular to the sun. We already have a couple of planes set up for this purpose so all you need to do is set r_HDRdebug  1 in the console and simply look at the surface. Keep in mind that turning this on brightens the whole scene so don’t forget to turn it off once you’re done measuring your illuminance.


Pic 9: Top - Fully lit area lux reading, Bottom - Shadow area lux reading

Rayleigh Scattering

This controls how much the sun light is scattered by the atmosphere. Set this to 1 for the whole timeline.

Wavelength (R/G/B)

The parameters that control the hue of the atmosphere are the Wavelength (R/G/B) values. We only need to set these once for the whole cycle.

Taken from the Wikipedia page on Diffuse Sky Radiation ( also known as Skylight ) we set these values at 650 (R), 550 (G), 450 (B).

Image Added

Pic 10: Screenshot from the Wikipedia page detailing Diffuse sky radiation.


Now that we have a smooth transition in the light intensity and color throughout the day we can continue to refine the appearance of the sky in relation to the time of day. For that we will be using fog.

Fog is used to enhance the depth of our scene and it’s also responsible for creating the haze at the horizon as well as the glow around the sun.

There are two different components that contribute to the fog:

  1.  The first one is a vertical gradient of fog throughout your level for which you can control the colors used ( Color bottom/top parameters ), the intensity of those colors ( Color bottom/top multiplier ) as well as the start/end height ( Height bottom/top ) and overall density ( Density bottom/top parameters ). Anything beyond the specified heights will use the defined color, multiplier and density for bottom and top respectively. Caution should be taken before using high fog density values as it can completely override the sky colors and dramatically change the look of your level. Basically fog should be used to enhance your scene and add more color to specific scenarios rather than fully control the appearance of your sky. With that in mind please note that it is possible to set the top density to a higher value than the bottom density. This will effectively flip the vertical fall off and produce thick fog in the sky and clear views at the bottom if such a result is desired. We also have the option to offset the transition between the top and bottom of this gradient by using the Color Height Offset parameter.
  2. The second component is the radial fog which controls the bloom around the sun. This can be used to enhance effects like the strong orange colors you’d expect to have around the sun at sunset/sunrise. We can specify the color/multiplier for it and we can control the size of the glow perpendicular to the camera ( Radial Size ) as well as the size towards the camera ( Radial Lobe ).

Inside the Fog group there are also settings that control the overall impact fog has over the level. The Final Density Clamp parameter controls the maximum density for the fog. This can be used in extremely foggy environments to avoid the background completely fading into the fog.

Global Density controls the overall fogginess of the scene so it multiplies on top of the top/bottom density values as well as the radial fog.

Here we also have the option to remove the fog around the camera and make it fade in at a specified distance. This can be achieved by using the Ramp Start/End/Influence parameters.

Lastly we have the Shadow Darkening settings that are only used to control the appearance of the fog in shadow areas. In order to enable the effect of these values VolFogShadows needs to be enabled in the Environment Panel. This is not to be confused with the Volumetric Fog in the Environment Editor which has a global influence.

Image Added

Pic 11: The Fog parameters section inside the Environment Editor.

Now that we have a better understanding of what the different settings for fog control we can continue setting up our day-night cycle.

Color ( bottom )

We start by setting the current time to 12:00 and assigning a light blue color ( 185, 251, 251 ). This value needs to stay consistent throughout the day and will start fading to almost black once we get close to sunset/sunrise. Create two more keys at 07:00 and 17:00 and assign the same color. After we’ve done that create a key at 06:00 and 18:00 and assign them a very dark grey color ( 13, 13, 13 ). Copy the same value to 00:00 and 23:59 to keep it constant for night time. We will be using this to create the illusion of light pollution on the horizon at night time.

Image Added

Pic 12: Color ( bottom ) curves setup.

Color ( bottom ) multiplier

Set this value to 3 for mid day and gradually drop it to 0.02 towards dusk/dawn. The reason for that is as the sun descends we need to allow the radial color to kick in so it creates the localized orange bloom around the sun. So we need a key at 12:00 with the value set to 3 and 4 more keys at 00:00, 06:00, 18:00 and 23:59 with the value set to 0.02.

 If you are wondering why this is set so low for night time it is because of the way eye adaptation works making the fog way too strong in low light conditions.

Image Added

Pic 13: Color ( bottom ) multiplier curves setup.

Height ( bottom )

We only need to set this once for the whole timeline so let’s set two keys at 00:00 and 23:59 with the same value of 70. We only have to do this because the Ocean height for our test level is set to 70 and we want the gradient to start at that height.

Density ( bottom )

We want the amount of fog to ramp up at sunset/sunrise. To achieve this set some keys at 06:00, 07:00, 17:00 and 18:00 wih a value of 0.3 then set 3 more keys at 00:00, 12:00 and 23:59 with a value of 0.2. As always make sure you have a smooth transition from one key to another by using editing their tangents.

Color ( top )

This value will be very subtle as we will be setting our top density quite low. For midday assign a light blue color , slightly darker than the bottom one, let’s say 131, 183, 231. At 07:00 and 17:00 change the value to a darker blue like 51, 72, 90. With the low density we will be using this color has no impact at night time. I have created more keys at 00:00, 06:00, 18:00 and 23:59 and set the value to black, but this is entirely optional.

Color ( top ) multiplier

The only key we need to create for this parameter is at 12:00 so change your current time accordingly and set the value to 1. Set the tangent to auto so it gradually transitions to 0 towards the ends of the timeline.

Height ( top )

We don’t need to change this value for this particular scenario.

Color height offset

As mentioned before this value can be used to offset the height of the transition between our top and bottom colors which is not necessary for our level.

Color ( radial )

Between 08:00 and 16:00 set this color to a light yellow like 193, 158, 100. As we get closer to the ends of our timeline this should transition into a gradually darker orange. To get this result set two keys at 07:00 and 17:00 and assign them a dark yellow color like 192, 126, 49 and leave the 00:00 and 23:59 times to their default value of black. Provided you’ve set up the curves properly this should give you the orange color when the sun is right above the horizon.

Color ( radial ) multiplier

To start with set this to 16 for mid day. The impact of the radial fog becomes more obvious as the light intensity drops so we will have to decrease the multiplier as we go towards the ends of the timeline. Create two keys at 07:00 and 17:00 set the value to 10.

It’s probably a good time to mention that the radial fog also gets applied to the moon during night time so if we keep our multiplier at 10, as soon as the sun goes under the horizon we will get a huge orange glow for the moon. To fix this create some keys at 05:55 and 18:05 and set the value to 0. It’s possible to set this up to control the bloom for the moon but there is a dedicated section for night sky. We will go over that later on.

Radial size

We only need to change this slightly to get a more pronounced effect. Set two keys with a value of 0.8 at the 07:00 and 17:00 times.

Radial lobe

Same as the Radial size, set this to 0.8 at 07:00 and 17:00 respectively.

Global density

As mentioned previously we want our fog to be denser in the morning/evening and fade out as the sun gets higher in the sky. Set a key at 12:00 and put in a value of 0.05. To handle the smooth transition add a few more keys at 00:00, 06:00, 18:00 and 23:59 with the value of 0.1.

These are all the parameters we need to change in the Fog section for our day-night cycle. By now you should have a fully working transition from dawn to dusk.

Next we will be setting up the values for night time in order to get a complete 24 hours cycle.