Ambient light is indirect, diffuse (scattered) ambient light, which in the real world comes from the sky as well as reflections. This can be achieved through the use of environment probes or global illumination (SVOGI). Without one of these sources of ambient light, shadows will be pitch black. The CRYENGINE sky emits no light, whereas on planet Earth, about 23% of sunlight is trapped by the atmosphere surrounding the planet, effectively forming a large, soft, ambient secondary light source (in addition to direct sunlight). The color of the light trapped in the atmosphere varies widely depending on the position of the sun relative to the viewer, from the blue of midday to the warm, saturated colors of sunset and sunrise.
In addition to not providing any actual illumination, the CRYENGINE sky created by Variables → Sky Light → Sun Intensity Multiplier differs from Earth's sky in one other respect: Earth's atmosphere thins as as you ascend above the surface, and with it, the appearance of a sky (created by sunlight trapped in that atmosphere) gives way to the blackness of space. However, the CRYENGINE "sky" is infinite. No matter how high you move the camera, you'll see the skylight color created by Variables → Sky Light → Sun Intensity Multiplier.
In essence, global volumetric fog, whose density you can attenuate with altitude by setting the top multiplier to a near-zero value, can essentially be used to model variable atmospheric density, since the sunlight scattered in the fog contributes greatly to the appearance of a sky.
Before enabling SVOGI, it's advisable to add specular reflections to your scene by adding at least one global environment probe (you'll probably end up adding many more, but it's advisable to build from the large to the small details).
Environment probes generate cube maps which are generated as .tiff files. A cube map consists of six still images taken from where the environment probe is located, as if looking perpendicular to the four sides of a cube as well as from above and below it. Those six images are then used to project specular reflections onto reflective surfaces. Since cube maps are static, specular reflections will not include moving entities. Also, if your lighting or environment changes, you'll need to re-generate all of your cube maps. (Level → Lighting → Regenerate All Cubemaps)
Environment probes can also be used to add diffuse (ambient) light through the diffuse multiplier property. However, if you enable SVOGI, the diffuse contribution of environment probes is ignored and replaced by SVOGI's ambient light (unless you enable Constants → Total Illumination Advanced → Use Light Probes to multiply the diffuse contribution of environment probes with SVOGI's, which is not commonly done.)
All levels should include at least one global cube map whose box size encompasses not only the heightmap dimensions, but also anything that you want reflected. (We typically set this to 10,000m in each dimension.) A global environment probe is typically centered over the height map.
If you aren't using SVOGI and want to generate ambient light from environment probes, you'll find that the vertical dimension of your box size can have a strong effect on how much ambient light you get out of an environment probe. Also, keep in mind that an environment probe's box size is extended in every direction from its pivot, which is centered within the entity, so make sure that wherever you have it positioned vertically above the heightmap that its box height is large enough to touch the lowest and highest points on your terrain or entities which you want reflected or affected by ambient light. It's helpful to keep your helpers on and keep the probe's pivot in your viewport so you can see the actual box size. Switching to wireframe view (Alt + W) is also helpful so you can see the probe's box under the terrain.
Interiors should each have their own additional cube map sized the same as the room. You may also want to add additional environment probes to lighten shadows in shady areas, like under heavy foliage.
However, the bottom line is that the ambient light produced by environment probes has a very flat quality that will not produce results as realistic as the gradients that SVOGI's ambient light can achieve. The tradeoff of using SVOGI is primarily performance and complexity; you might spend more time testing and adjusting SVOGI's parameters to balance appearance and performance, but in the end, you'll get better results.
For now, let's add one global environment probe. Make sure your helpers are enabled (Ctrl + H):
Maximum Attenuation Falloff = 64000 (hard edges) | Maximum Attenuation Falloff = 1 (soft edges) |
---|---|
Maximum Attenuation Falloff = 1, boxes overlapping to blend | |
The SVOGI system is based on voxel ray tracing and provides dynamic and indirect bounce lighting from static and most dynamic objects, provides large scale ambient occlusion and indirect shadows from static geometry. In plain English, it provides diffuse ambient light (effectively the otherwise missing skylight when sun intensity > 0) and reflected light through a single bounce of direct light sources (in the default mode).
While it's possible to supply ambient light solely through carefully placed environment probes, you'll see significant advantages by enabling global illumination. For example, you'll notice realistic soft gradients transitioning from light to shadow areas with SVOGI vs. cubemaps, as you can see in these images.
While you'll see many settings for the GI (global illumination) system in the Environment Editor as well as console variables, the default values have been set to be suitable for most realistic use cases, and many of them needn't be changed. Let's review some of the key parameters that you will need to adjust to suit your needs.
One important aspect of the SVOGI system to note: if SVOGI → Use TOD Sky Color is set to a value greater than 0, then the ambient light generated by SVOGI will be affected by Fog → Color (top) - even if volumetric fog is enabled. The higher you set Use TOD Sky Color, the more the Fog → Color (top) is going to affect the ambient light generated by SVOGI.
Effectively, enabling SVOGI during the day (when sun intensity is greater than zero) provides skylight luminance, whose intensity and color are affected by these three parameters in the Environment Editor:
This is the short list of steps to setting up GI; details and guidelines for each setting appear in the next section.
With regard to step 4, GI leaking happens when a mesh is too thin, and can only be fixed be editing the mesh in your DCC tool (or the Designer Tool, if it's a Designer object).
While the vast majority of GI settings can be left at their defaults, you'll want to pay particular attention to these and adjust them to your liking:
Most other parameters are typically best left at the default values.
In the Properties → Options → Global Illumination section of the Properties panel for light components, there are a couple of important settings that affect how the light will behave with respect to global illumination:
Under Material Editor → Advanced → Voxel Coverage, this setting controls how “transparent” the material is in terms of the GI. 0 means that GI light will transmit completely through the material; 1 means the material will block all GI light.
Mesh components have one GI setting under Properties → Rendering Settings → GI and Usage Mode that determines how they interact with the GI system. Here's a comparison of how these options look with a large reflector with a pink diffuse color bouncing sunlight (coming from the left) onto the GameSDK Humvee and hangar. If the color of the material on the reflector changed, it would change the color of the bounced light. The injection multiplier has been set quite high (12) to make it easy to see the bounce light.
GI and Usage Mode = Disabled | GI and Usage Mode = Static Voxelization |
---|---|
Even if GI and Usage Mode is left disabled (the default setting), the mesh still interacts with the GI system, receiving and bouncing GI light. You'll notice in the second row of images (with voxelization revealed through e_svoDebug 6) that neither the Humvee nor the reflector are voxelized, yet GI is clearly in effect, as evidenced in the third row of images, where the output of the GI system is revealed through r_ShowRenderTarget svo_fin.
Static Voxelization mode, seen in the right hand column, provides more accurate bounce light, as you can readily see, as well as in-directional occlusion effects and large scale ambient occlusion. This is the recommended setting for meshes in a level where SVOGI is enabled.
While additional options are offered for analytical occlusion, this should be regarded as still experimental. Read more about using analytical occluders here.
Similar to the GI and Usage Mode on mesh components, brushes have a setting to enable or disable voxelization: Global Illumination. If you enable this property on a brush, be sure to open the environment editor and toggle Constants → Global Illumination → Update Geometry off and then on to force re-voxelization. Use e_svoDebug 6 in the Console window to verify that the brush is being voxelized.
r_profiler 1: GPU profiling information | r_profiler 2: detailed rendering statistics |
---|---|
Even after getting your sunlight, skylight, fog, and SVOGI settings configured to your liking, you may still find that interiors, particularly during the day when there is no reason for electric lights to be on, are too dark. In these cases, the best approach is to supplement sunlight using projector lights through any windows. To avoid limitations with the number of simultaneous shadow casters, you can make projector lights look less obvious and hard-edged by adding projection textures in Properties → Projector Options → Projected Texture to break up the wash of light. Any subtle noise pattern will help. This is exactly the approach we took to light interiors on Hunt: Showdown, with projector lights mimicking sunlight in many cases. See the Creating Your Own Projection Textures section of the projector light component tutorial for details.
If your terrain heightmap has significant hills and valleys, you'll need to enable the engine to cast shadows from the heightmap itself. In other words, the mountains should create shadows in the valleys.
You enable this in Level Settings → Env State → Sun Shadows From Terrain. However, if you have SVOGI enabled, you also need to enable it in SVOGI, otherwise you'll see disappearing and appearing terrain shadows when the camera moves closer and farther away.
You'll find those settings in the Environment Editor under Constants → Total Illumination Advanced → Shadows From Sun and Shadows From Heightmap. If you’re still seeing terrain shadows come and go, you could try disabling shadow caching with r_ShadowsCache 0 in the Console. Note that you may see pixelated edges to the terrain shadows. If possible, try working with Constants → Total Illumination Advanced → Shadows From Sun in the Environment Editor off to remove that artifact.
If your terrain is flat or your sun is very high overhead, you don’t need to bother with this.
While Level Settings are environment-related settings, remember that they’re saved with the level, not with the environment preset, so if you switch environment presets during a game, you may also need to tweak some of your level settings to give you the look you want. For example, you'll find volumetric cloud settings both in the Environment Editor and in Level Settings.
Shadows from heightmap OFF | Shadows from heightmap ON |
---|---|
If you're a lighting artist capturing beauty shots for your portfolio, you have the luxury of not worrying about real time performance, and may want to adjust the following parameters as indicated to optimize the visual benefits of SVOGI. Just don't forget to restore these parameters to their original values before saving your environment preset, or else your performance will plummet!
This tutorial is also available in video form on our YouTube channel: