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.
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.
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. |
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). |
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. |
FallOffShift | Controls how much to shift the fog density distribution along the fall off direction in world units (m). |
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. |
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. |
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. |
e_Fog e_FogVolumes
Activates global height/distance based fog
Activates local height/distance based fog volumes
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.