Setting Up Time Of Day

Overview

CRYENGINE includes a CGI quality Time Of Day lighting system. Designers can use the Time Of Day function to simulate realistic and surrealistic lighting effects.

After completing this tutorial, you will be able to use the Time Of Day function, the Terrain Lighting dialog box, and the Terrain -> Environment panel in the RollupBar to configure precise lighting conditions.

Time Of Day Dialog Box

The Time Of Day dialog box is used to configure the lighting and environment settings of a level. All values can be animated over time so that the level will look different as time advances.

Open the Time Of Day function through the Terrain menu. You can also find a "Time Of Day" button in the main toolbar.

A simple way to get started is to import the default Time Of Day setup included with Sandbox. This .xml (formerly .tod) file can be found in the Sandbox Editor directory: <root>\Editor\default_time_of_day.xml.

The Time of Day window will typically open with just the basic properties listed but you can toggle between the basic and advanced properties, by selecting the Toggle Advanced Properties option on the left hand panel.

A complete list of the parameters and their functions can be found at the end of this tutorial. There are also additional parameters which can be accessed via the Rollup Bar -> Terrain -> Environment tab.

Static Versus Dynamic Skies

Some of the parameters described on this page are relevant only to either Dynamic (HDR sky) or Static (Skybox). The latter are simple boxes that use textures to render a sky dome; hence, they cannot offer all the dynamic effects exposed by HDR sky and the Time Of Day system.

It is important to remember that the sky and time of day can be configured on a level per level basis. Dynamic skies use a material that has the "SkyHDR" shader assigned. Static skies use a material with the "Sky" shader and combines textures containing the five sides of the sky box (all cube sides, except the bottom). To manipulate the sky, create or pick an appropriate material and assign it to the sky dome through RollupBar -> Environment -> Skybox -> Material/MaterialLowSpec. You must also have the "Skybox Multiplier" value set to '1' in the Time of Day properties.

User Interface

To store the changes made in the parameters panel, the red record button in the top panel needs to be highlighted. The Time Of Day dialog box has a slider that represents a 24 hour day. It can be used to set the current time and can also be used to scroll or scrub through the entire 24 hour cycle.

All the parameters that are changed in the right panel will be set for the currently selected time. The graph in the center of the dialog box shows the change of the highlighted parameter over time. When a parameter in the right panel is changed, the graph curve will be updated at the currently selected time. It is also possible to directly change the curve by dragging around the key frame points. New key frames can be inserted by double-clicking the curve and existing ones can be removed by double-clicking the key frames themselves.

It is important to realize that each yellow dot in the graph for each property is a key frame and times that lie between these keyframes will have their values interpolated.

Time Of Day Tasks

Description

Import From File

Imports the Time Of Day settings from an XML/TOD file.

Export To File

Exports the Time Of Day settings to an XML file.

Reset Values

Resets all the parameters to their default values.

Expand All

Expands all the parameter group panels.

Collapse All

Collapses all the parameter group panels.

Toggle Advanced Properties

Toggles the properties view panel on the right to either show just the basic properties or all available properties.

Current Time

Current Time

Displays the current time that is being edited.

Start Time

Initial time that will be used when the mission is started.

If you do not set this value correctly, your TOD will not be set correctly in pure-game mode.
If you have Current Time set to 07:00 and Start Time set to 12:00, it will be 12:00 in pure-game mode and 07:00 in Sandbox.

End Time

End time that will be used for the mission. If the end time is set to 23.59, the time will loop, starting the next Time Of Day cycle once a day is over.

Play Speed

Speed at which the time advances; 0.005 is a good general value.

Update Tasks

Play

Starts or resumes the playback of the Time Of Day sequence in the Editor.
If the current time is not within the specified time range (between the start and end time), frame playback begins at the specified start time.

Stop

Stops the playback of the Time Of Day sequence in the Editor.

Force Sky Update

Selecting this check box forces a complete update of the sky light calculations in each frame.
If the check box is deselected, calculations are distributed over several frames and it can take some time until the effect of the modified parameters becomes visible.

The Terrain Lighting Dialog Box

See Terrain Lighting Tool for more information.

Cloud Shadows

See Cloud Shadows for more information.

Environment Panel

See Environment Panel for more information.

Time of Day Parameters Settings

Sky Parameters

Parameter

Description

HDR dynamic power factor

The dynamic power factor is applied to all the light sources, when rendering in the HDR mode.
When HDR is enabled, eye adaption is usually applied, which brightens up dark scenes and dims down bright scenes.
As a consequence, more light intensity range is required so that HDR scenes look similar to LDR scenes.
When the HDR Dynamic Power Factor is set to 0, no change in brightness will be applied to the HDR light sources.
Positive values will brighten up the lighting, while negative values will darken it.

This value should be left at 0 to maintain consistent and accurate lighting results. It will be removed in future updates. Use the HDR Curve Editor controls instead.

Sky brightening (terrain occlusion)

DEPRECATED (3.6) - This value specifies how much ambient occlusion on terrain, under trees, and the like, should be visible.
A value of 0.0 results in full ambient occlusion, whereas a value of 1.0 results in no ambient occlusion at all (ambient term is equal to the current sky color).

Global illumination multiplier

This value specifies how strong the global illumination will be.

Sun color

This RGB value sets the color of the light source used as the sun.

Sun color Multiplier

This value specifies the brightness of the sun and gets multiplied with the sun color.

Sun specular Multiplier

An additional control for the brightness of the sun, allowing you to increase the intensity and brightness of the sun on specular materials in the world.

Fog Parameters

Parameter

Description

Color (bottom)

This allows for gradient coloring of the global fog. This value will be the bottom color of the fog

Color (bottom) multiplier

This value is multiplied by the bottom fog color and specifies the brightness of the top fog color.

Height (bottom)

Specifies a reference height for the vertical fog gradient (in range [-5000..35000], default is 0).
For the fog color this marks the height at which it will reach the specified color at the top.
For the fog density it marks the height at which the vertical density fall off reaches the specified density.

Density (bottom)

Density at the top (in range [0..1], default is 1). 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. Also note that both top and bottom density can be equal.
In this case you create a fog effect that is entirely depth based only. It is also important to understand that the volumetric fog computations treat a level as a continuous unbound volume.
That means specifying a density > 0 at your given top height doesn't mean that fog will suddenly stop there but instead continues to gradually fall off.
The same is true for the bottom boundary or density values < 1.

Color (top)

This allows for gradient coloring of the global fog. This value will be the top color of the fog.

Color (top) multiplier

This value is multiplied by the top fog color and specifies the brightness of the top fog color.

Height (top)

Specifies a reference height for the vertical fog gradient (in range [-5000..35000], default is 4000).
For the fog color this marks the height at which it will reach the specified color at the top.
For the fog density it marks the height at which the vertical density fall off reaches the specified density.

Density (top)

Density at the top (in range [0..1], default is 1). 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.
Also note that both top and bottom density can be equal. In this case you create a fog effect that is entirely depth based only.
It is also important to understand that the volumetric fog computations treat a level as a continuous unbound volume.
That means specifying a density > 0 at your given top height doesn't mean that fog will suddenly stop there but instead continues to gradually fall off.
The same is true for the bottom boundary or density values < 1.

Color height offset

Shifts the color of the vertical fog gradient towards the top or bottom (in range [-1..1], default is 0).

Color (radial) & multiplier

Specifies the color of the fog component responsible for producing halos around the sun and in-scattering of sun light.

Radial size

Specifies the size of the radial fog component (in range [0..1], default is 0.75).

Radial lobe

Specifies how much the radial fog component is affected by distance (in range [0..1], default is 0.5).
Small values will make it affect the horizon only while bigger values will make it appear to over glow the scene.


On the left is a Radial Lobe of 0 (note sharp horizon) and on the right is Radial Lobe of 0.3 (note blurred horizon).


Be aware that too high Radial Lobe value will cause it to project in front of objects. 1 on left, 0 on right.

Final density clamp

Specifies the maximum fog density that is allowed for final blending with the scene (in range [0..1], default is 1).
This allows the sky, horizon and other bright distant objects to punch through even if the fog is dense.
However, care should be taken to not set this value too low as otherwise depth perception is compromised and will result in implausible visuals and seemingly apparent artifacts especially when moving the camera.

Global density

This value specifies the global density of the volumetric fog. Higher values produce denser fog.

Ramp start

The ramp values can be used to control the fog density in relation to the camera.
This value sets the distance from the camera at which the fog will start to be rendered (at 0 density).

Ramp end

This sets the distance from the camera at which the fog will be rendered at its maximum density, set by the Global Density parameter.

Ramp influence

This value determines how much the ramp values effect the rendering of the fog.

Shadow darkening

Specifies how much the fog color computed per pixel (via the settings above) is generally darkened based on the volumetric shadow value computed by the engine per pixel (in range [0..1], default is 0.25).
The factor is applied after a darkened fog color has been calculated using the sun and ambient darkening factor below.

Shadow darkening sun

Specifies how much the radial fog color is influenced individually (in range [0..1], default is 1).

Shadow darkening ambient

Specifies how much the ambient fog color (i.e. height gradient) is influenced individually (in range [0..1], default is 1).

Shadow range

Specifies how far volumetric shadows get traced (in range [0..1], default is 0.1; that is, up until 10% of the level's far clip plane distance).
Please note that the number of samples per view ray do not increase so smaller values will result in more accurate results but shadows won't cast that far.

Sky Light

Please note that these parameters are ignored when a static sky is used.

Parameters in this section are solely used to compute the atmospheric appearance of a dynamic sky. They do not directly affect the rendering of objects in the world (for example, lighting colors and intensities).

However, they are used to internally compute an approximate fog color to automatically fog the entire scene in appropriate colors. For a static sky, only the fog color in the fog parameter group is used.

For a more in-depth explanation of the physical scattering parameters listed below, please refer to this page.

Parameter

Description

Sun intensity

A RGB value specifying the sun color that is used to compute the atmosphere color.

Sun intensity multiplier

This value sets the brightness of the sun. It gets multiplied by the sun intensity to yield the overall color.
Higher values will result in brighter skies. Fading down this value during the day time helps simulate an eclipse.

Mie scattering

This parameter sets the Mie scattering constant. Mie scattering is caused by aerosols in the lower atmosphere (up to 1 km).
It is wavelength independent and responsible for haze and halos around the sun on foggy days.
Smaller values result in a clearer sky. Bigger values make the sky appear hazier. A good default value for the Mie scattering constant is 4.8.


A Mie scattering constant of 2.0 (left), of 100.0 (middle), and of 2000.0 (left).

Rayleigh scattering

This parameter specifies the Rayleigh scattering constant. Rayleigh scattering is caused by particles in the atmosphere (up to 8 km) and is wavelength dependent.
With a default value of around 2.0, it produces typical earth-like sky colors (blue sky during the day, reddish/yellowish colors at sun set, and the like).
Higher values cause a denser atmosphere, with sky colors shifting towards red and yellow. Smaller values produce a bluer sky.


A Rayleigh scattering constant of 2.5 (left) and of 4.8 (right).

Sun anisotropy factor

The anisotropy factor controls the sun's appearance in the sky. The closer this value gets to -1.0, the sharper and smaller the sun spot will be.
Higher values cause more fuzzy and bigger sun spots. A good default value is -0.995.


A sun anisotropy constant of -0.999 (left) and of -0.8 (right).

Wavelength R, G, and B

This triple defines the wavelengths (in nm) of the RGB primaries. Tweaking these values will shift the colors of the resulting gradients and produce different kinds of atmospheres.
This can be very useful in combination with Rayleigh scattering if you choose a sun intensity of pure, bright white.


RGB wavelengths of RGB=(650.0, 570.0, 475.0) (left) and RGB=(750.0, 601.0, 555.0) (right).

Night Sky and Night Sky Multiplier

Please note that all the parameters in this section are ignored when a static sky is used.

Parameter

Description

Horizon color & multiplier

This RGB value that is scaled by the multiplier specifies the horizon color of the night sky gradient.

Zenith color & multiplier

This RGB value that is scaled by the multiplier specifies the zenith color of the night sky gradient.

Zenith shift

This value shifts the night sky gradient. Small values shift it more towards the bottom. Higher values shift it towards the top.


A zenith shift of 0.2 (left) and of 0.8 (right).

Star intensity

This value controls the overall brightness of the stars.
Please note that the flickering of stars due to atmosphere turbulence is completely procedural and cannot be controlled.

Moon color & multiplier

This RGB value that is scaled by the multiplier specifies the moon's emissive color.

Moon inner corona color & multiplier

This RGB value that is scaled by the multiplier specifies the color of the moon's inner corona.

Moon inner corona scale

This value controls the size and blurriness of the moon's inner corona.
Smaller values will produce a bigger, blurry corona.
Higher values will produce a smaller, more focused corona.

Moon outer corona color & multiplier

This RGB value that is scaled by the multiplier specifies the color of the moon's outer corona.

Moon outer corona scale

This value controls the size and blurriness of the moon's outer corona.
Smaller values will produce a bigger, blurry corona.
Higher values will produce a smaller, more focused corona.


Different moon corona inner and outer scales: 0.5/0.01 (left), 0.5/0.5 (middle), and 1.5/0.05 (right).

Cloud Shading

All types of clouds supported by the engine (distance clouds, impostor clouds, and volumetric clouds) use the current sky and sun color, along with per material albedo to shade the clouds.

As sun and sky color can be slightly too bright or dark in certain scenarios, the following two parameters provide means to correct the cloud brightness for a given time of day.

Parameter

Description

Sun contribution

This value specifies how much the sun affects the cloud brightness.

Sky contribution

This value specifies how much the sky light affects the cloud brightness.

Sun custom color

Sun custom color multiplier

Sun custom color influence

Sky custom color

Sky custom color multiplier

Sky custom color influence

Sun Rays Effect

Parameter

Description

Sun shafts visibility

DEPRECATED - This value controls the visibility of sun shafts.
Higher values accentuate the shadow streaks that are caused by the sun light penetrating objects.

Sun rays visibility

This value controls the visibility of sun rays. Higher values cause brighter rays around the sun.

Sun rays attenuation

This value controls the attenuation of sun rays. Higher values cause shorter rays around the sun.

Sun rays suncolor influence

This value controls how much the sun color contributes to the color of the sun rays.
If the parameter is set to 1.0, the sun rays get the color of the sun.
If it is set to 0.0, the rays use the custom color. Values in between interpolate between the custom and sun color.

Sun rays custom color

This value specifies a custom color for the sun rays.


Sun shafts and sun rays combined, with the following values from the left to the right image:
(sun shafts visibility/sun rays visibility/sun rays attenuation) = 0.0/0.0/1.0, 1.0/0.0/1.0, 1.0/2.0/1.0, 1.0/2.0/0.5.

Advanced

Parameter

Description

Ocean fog color

This RGB color specifies the ocean fog color for a specific time of day.

Ocean fog color multiplier

This parameter controls the brightness of the ocean fog and is multiplied by the ocean fog color.

Ocean fog density

This value controls the density of the ocean fog.

Skybox multiplier

This value controls the brightness of a static skybox. This parameter is not used for a dynamic sky.

This must be set to '1' when using a static skybox.

Filters

Parameter

Description

Grain

This parameter applies a grain filter to the final image.

Sharpening

This parameter applies a sharpening filter to the final image.

Photofilter color

This parameter applies a color filter to the final image.

Photofilter density

This parameter controls the strength of the photo color filtering.

Depth of Field

Parameter

Description

Focus Range

This parameter specifies at what distance the background begins to become blurry (out of focus).

Blur Amount

This parameter controls how strong areas that are out of focus, are blurred.

Shadows

The parameters in this section give you control over the sun's cascaded shadow map bias settings at different ranges. It does not affect point lights (bias settings can be defined per light in the light properties).

Parameter

Description

Bias

Moves the shadow cascade toward or away from the shadow-casting object (or objects).

Slope Bias

Allows you to adjust the gradient (slope-based) bias used to compute the shadow bias.

Shadow jittering

Customize the sharpness of the shadows.

CRYENGINE supports multiple cascades. Cascade 0 is closest to the camera, cascade 1 is further, etc. The higher the cascade, the lower the precision of the shadows (lower resolution for higher cascades).

Shadow map acne is usually visible at medium range on the 3rd and 4th cascade especially. To prevent shadow map artifacts, the sun shadows bias and slope bias settings are exposed in the time of day.

Shadow Bias

The lower the “Bias”, the more connected the shadows will be to the shadow caster.

In most cases, the "Bias" should be kept as low as possible, to ensure a proper connection between the shadow and the shadow caster. Values between 0.01 and 0.05 offer the best compromise.

Bias = 0Bias = 0.05
Bias = 1Bias = 5
Shadow Slope Bias

The higher the "Slope Bias", the less shadows will be cast from surface with a high angle of incidence of the light.

In most cases, you want to keep the “Slope Bias” at a fairly high value, to remove the artifacts usually produced by the low shadow bias. Values between 32 and 64 offer the best compromise.

Slope Bias = 8Slope Bias = 32
Slope Bias = 64Bias = 0.025 / Slope Bias = 32

In the last image above, a compromise was made between Bias of 0.025 and Slope Bias of 32. Some artifacts are visible, but the self shadowing is better overall.

There is no "one-size-fits-all" setting for shadow cascades. It depends on your assets, sun position, lighting conditions, etc. Tweak these settings to suit your needs and keep in mind they have little to no impact on performance.

Shadow Jittering

Shadow Jittering can be defined through Time of Day (as well as r_ShadowJittering CVar) to give you control over shadow sharpness.

Note that the more jittering that is used, the heavier on performance it is.

Shadow Jittering = 2.5 (default)Shadow Jittering = 1Shadow Jittering = 10

HDR Curve Editor

Parameter

Description

Film curve shoulder scale

Controls the slope at the tip of the curve (modified bright values).

Film curve midtones scale

Controls the linearity of the middle of the curve (modifies grey values).

Film curve toe scale

Controls the slope at the base of the curve (modifies dark values).

Film curve whitepoint

Sets the value to be mapped as pure white in the tone mapped image.

Saturation

Color saturation before tone-mapping.

Color balance

HDR Color balance to control overall color of the scene.

Scene key

Overall brightness of the scene used for the automatic eye adaptation.
Tweaked depending on the scene brightness, lower value for night/dark scenes, higher values for daylight/bright scenes.

Min exposure

Darkest possible exposure used for the automatic eye adaptation.

Max exposure

Brightest possible exposure used for the automatic eye adaptation.

Bloom amount

Controls the amount of bloom that comes from glowing/lit objects.