Fog

Overview

Global volumetric fog in CRYENGINE allows you to model almost all aspects of Aerial Perspective. It simulates particles/aerosols distributed uniformly along the ground plane and falling off exponentially with height (based on height above sea level).

The fog integral between the viewer and each pixel in the scene gets properly solved taking the two mentioned distributions into account. Additionally, it accounts for sunlight scattered into the view ray to produce halos around the sun in foggy environments.

Only reflected sunlight from the ground is not considered since there's no closed form to solve the integral. Luckily, it can safely be ignored as it only has a minor impact on the final result.

Time of Day Fog

Most volumetric fog parameters are directly editable in the editor's Time of Day window under Fog. There are also a few parameters in other subsections which contribute to the result of the volumetric fog computation.

Make sure you read up on the Time of Day documentation to discover how to tweak environment fog for your level.

Fog (Obsolete)

Obsolete
Due to major changes to the Volumetric fog system, this entity is now obsolete. Use Fog Volumes instead and/or modify Fog values via the Time of Day tool.

The Fog entity is used to overwrite the fog effect in specific areas. In indoor areas a subtle fog effect can be added to simulate a dusty area.

To use, create an area shape and link the shape to the Fog Entity. When in game mode, you can walk into the area and see how the fog gets different inside. Outside Game mode the fog is not visible.

Property

Description

AtmosphereHeightModifier

Defines the height of the density above sea level. The higher the atmosphere the less visible the effect of horizontal fog layers.

FadeTime

Sets up the time in which the fog takes to fade in.

GlobalDenstiyModifier

Specifies the density of the fog.

Fog Volumes

FogVolumes exhibit the same properties of global volumetric fog, with the added benefit of locality. Currently supported volume types are boxes and ellipsoids (including spheres as a special case).

The benefit of using a FogVolume is that it is possible to define fog volumes that can be non-uniformly scaled along their major axes, rotated, and have an arbitrary fall-off direction (unlike global volumetric fog which defines the world space up-vector as its fall off direction).


A HMMWV inside two fog volumes - One large (brown) and one small radius (orange).

Fog volumes are placed as entities via RollupBar -> Entity -> Render -> FogVolume. Drag the entity into the perspective viewport to place it. You should be see a white, spherical fog volume.

Translation and Rotation of a fog volume entity is performed via the move and rotate edit mode just like for any other object. Non-uniform scaling will distort the entity and produce incorrect rendering results.

Parameter

Description

Active

If true, fog volume will be enabled.

Color

Specify the RGB diffuse color of the fog volume.

DensityOffset

Offset fog density, used in conjunction with the GlobalDensity parameter.

FallOffDirLati

Controls the latitude of the world space fall off direction of the fog. A value of 90° lets the fall off direction point upwards in world space (respectively, -90° points downwards).
All values in-between create a direction along the specified longitude.


longitude 0°, latitude 90° / longitude 330°, latitude 45°

FallOffDirLong

Controls the longitude of the world space fall off direction of the fog. 0° represents East, rotation is counter-clockwise.

FallOffScale

Scales the density distribution along the fall off direction. Higher values will make the fog fall off more rapidly and generate thicker fog layers along the negative fall off direction.


Scale set to 0.5 and 2.0 (from left to right)

FallOffShift

Controls how much to shift the fog density distribution along the fall off direction in world units (m).
Positive values will move thicker fog layers along the fall off direction into the fog volume. Negative values will move thick layers along the negative fall off direction out of the fog volume.


Shift set to -1.0 and 1.0 (from left to right)

GlobalDensity

Controls the density of the fog. The higher the value the more dense the fog and the less you'll be able to see objects behind or inside the fog volume.

HDRDynamic

Specifies how much brighter than the default 255,255,255 white the fog is.

NearCutoff

Stop rendering the object, depending on camera distance to object.

SoftEdges

Specifies a factor that is used to soften the edges of the fog volume when viewed from outside.
A value of 0.0 produces hard edges. Increasing this value up to 1.0 will gradually soften the edges. This property currently has no effect on Box type Fog Volumes.

UseGlobalFogColor

If true, the color property is ignored. Instead, the current global fog color is used. Please refer to the Volumetric Fog page for further information.

VolumeType

Specifies the volume type. The following types are currently supported: 0 - Ellipsoid, 1 - Cube.


Type 0 - Ellipsoid (left), Type 1 - Cube (right)

Size

The height/width/depth of the fog volume in world units (m). Non-uniform scaling is possible so height, width and depth don't have to be the same.

Tips and Troubleshooting

  • Fog volumes should not overlap. In some situations (i.e. clever placement of volumes) it might work but in general it won't. Fog volumes are internally treated and processed like alpha-transparent objects so the general sorting issue of these apply here as well. However, inclusion should work as it is guaranteed that smaller ones never overlap with bigger ones.
  • Even though alpha-transparent objects behind fog volumes will be fogged per-pixel, this is not the case for when they are inside fog volumes.
  • Fog densities cannot change in dynamic, non-uniform way (smoke-like). A particle effect with soft particle blending enabled is much better suited for that purpose.
Debugging

e_Fog

Activates global height/distance based fog

e_FogVolumes

Activates local height/distance based fog volumes

Troubleshooting

Q: Shadow maps inside fog volumes do not work, what's wrong?

Make sure you have the cast/receive shadow flag unchecked for each fog volume entity.

Q: In indoors fog volumes sometime suddenly disappear when player moves around, how can this be fixed?

Make sure your fog volume entity doesn't cover more than one sector. They'll otherwise get culled when the main sector they were registered to becomes invisible.