Volumetric Fog

Overview

Voxel-based Volumetric Fog is a new feature that uses volume textures as a view-frustum-shaped voxel buffer to store the incoming light and properties of participating media.

The older Volumetric Fog system can only handle sun with dynamic shadow and exponential height fog density, also in dense fog situations the fog's appearance is not consistent between opaque and transparent materials.

This new voxel-based Volumetric Fog system can handle sun with dynamic shadow, environment probes, ambient light, and regular light with dynamic shadows, as well as variations in fog density. It also supports the application of Volumetric Fog in a consistent way in respect to opaque and transparent materials.

Voxel-based Volumetric Fog consists of two parts; 1: ray-marching Volumetric Fog and 2: analytical Volumetric Fog.

Ray-marching Volumetric Fog handles all types of light and differing fog densities, while analytical Volumetric Fog handles sun light without dynamic shadow and exponential height fog density.

The area near to the camera is covered by ray-marching Volumetric Fog, while everything else is covered by analytical Volumetric Fog.

Usage

To enable Volumetric Fog in your level, set the CVar e_VolumetricFog=1 in the console window or by adding it to the system.cfg.

Volumetric Fog Appearance

Voxel-based Volumetric Fog control is handled via the parameters found in the "Volumetric Fog" group in the Time of Day dialog window. (See picture above).

Volumetric Fog appearance types are controlled through various parameters and as listed in the table below.

ParameterDescription
Anisotropy (entities)Adjusts the anisotropy of all participating media (e.g. fog volume) except the global fog. Where 0 = isotropic, 1 = perfect forward, -1 = perfect backward in-scattering.
RangeAdjusts the maximum distance of ray-marching Volumetric Fog. The out of range is covered by analytical Volumetric Fog. (Default setting = 64).
In-scatteringAdjusts the factor of in-scattering of all participating media.
ExtinctionAdjusts the factor of extinction of all participating media.
Analytical fog visibilityAdjusts the visibility of analytical Volumetric Fog. Where 0 = no analytical Volumetric Fog, 1 = visible analytical Volumetric Fog.
Final density clampAdjusts the maximum range of fog effect.

Global Fog - Time of Day

Global fog control parameters are found in the "Volumetric Fog" group. The "Volumetric Fog" group can be found in the Time of Day dialog window.

ParameterDescription
Height (bottom)Specifies the height of the bottom.
Density (bottom)Specifies the fog density scale of the bottom.
Height (top)Specifies the height of the top.
Density (top)Specifies the fog density scale of the top.
Global densityAdjusts the global fog density.
Ramp startSpecifies the start distance of fog density ramp.
Ramp endSpecifies the end distance of fog density ramp.
Color (atmosphere)Specifies the fog albedo color for sun atmosphere scattering.
Anisotropy (atmosphere)Adjusts the anisotropy for sun atmosphere scattering. Where 0 = isotropic, 1 = perfect forward, -1 = perfect backward in-scattering.
Color (radial)Specifies the fog albedo color for sun radial scattering.
Anisotropy (radial)Adjusts the anisotropy for sun radial scattering. Where 0 = isotropic, 1 = perfect forward, -1 = perfect backward in-scattering.
Radial blend factorAdjusts the blend factor of blending sun atmosphere and sun radial scattering.
Radial blend mode

Adjusts the blend mode factor of blending sun atmosphere and sun radial scattering. Blending is achieved as follows:

sun scattering = ((1.0 - blend factor * blend mode) * sun atmosphere) + (blend factor * sun radial)

blend mode = 0 means completely additive blending.

sun scattering = sun atmosphere + (blend factor * sun radial)

blend mode = 1 means completely linear interpolation.

sun scattering = ((1.0 - blend factor) * sun atmosphere) + (blend factor * sun radial)

Color (entities)Specifies the global fog albedo color for scatterings of all types of light except the sun.
Sun Radial Scattering Setup

Anisotropy(atmosphere) and Anisotropy(radial) parameters essentially work in the same way. Anisotropy(atmosphere) should be used to produce an atmospheric fog that covers the whole sky - to achieve this set a low value (close to 0.0). Anisotropy(radial) should be used to produce a bloom effect around the sun - to achieve this set a high value (close to 1.0). The Radial blend factor blends these two fog components to create various fog effects.

Setting the Radial blend mode = 1 and the Radial blend factor = 0.0 allows you to see sun atmosphere scattering only, hence checking the results of adjusting the Color(atmospheric) and the Anisotropy(atmosphereic) on your fog effect can easily be achieved. The Anisotropy parameter allows you to control how much incoming light is scattered and in which direction, while setting the Anisotropy(atmosphere) parameter close to 0 makes the scattering more isotropic and therefore produces a uniform atmospheric fog.




Next, setting Radial blend mode = 1 and Radial blend factor = 1.0 allows you to see sun radial scattering only, hence checking the results of adjusting the Color(radial) and Anisotropy(radial) on your fog effect can easily be achieved. Adjusting the Anisotropy(radial) parameter to high (0.95) makes a scattering more anisotropic and therefore produces a bloom effect around the sun.



Finally, adjusting Radial blend factor parameter between 0 and 1 blends the sun atmosphere scattering and sun radial scattering, hence the final result becomes a more life-like atmospheric fog effect.

Fog Volume

To control the local fog density and color, put the FogVolume entity into a level and add a fog density and color into the area.

The following parameters have been added for voxel-based Volumetric Fog.

ParameterDescription
ActiveOn/Off.
AffectsThisAreaOnlySetting to false ensures the FogVolume entity effect occurs in multiple VisAreas and ClipVolumes.
ColorRGB
DensityNoiseOffsetOffsets the noise value for the density.
DensityNoiseScaleScales the noise value for the density.
DensityNoiseTimeFrequencyControls the time frequency of the noise for the density. High frequencies produce fast changing fog.
DensityOffsetAdditional controls to the density of the fog volume.
FallOffDirLatiDirection of the fall off (latitude). 90 = up
FallOffDirLongDirection of the fall off (longitude). 0 = East (Positive X)
FallOffScaleScales the density distribution along the fall off direction. Higher values will make the fog fall off more rapidly.
FallOffShiftControls how much to shift the fog density along the fall off direction.
GlobalDensityControls the density of the fog volume.
HDRDynamicDeprecated.
IgnoreVisAreasControls whether the FogVolume entity should respond to VisAreas and ClipVolumes.
NearCutOffStops rendering the volume, depending on the camera distance to the object (m).
RampStartSpecifies the start distance of fog density ramp in world units (m).
RampEndSpecifies the end distance of fog density ramp in world units (m).
RampInfluenceControls the influence of fog density ramp.
SoftEdgesSpecifies a factor that is used to soften the edges of the fog volume when viewed from outside.
UseGlobalFogColorIf true, the entities Color property is ignored. Instead, the current global fog color is used.
VolumeTypeSpecifies the volume type. 0 - Ellipsoid, 1 - Cube.
WindInfluenceControls the influence of the global wind upon the fog volume.
DensityNoiseFrequency XYZControls the spatial frequency of the noise for the density. High frequencies produce highly detailed fog.
Size XYZSets the size limits of the fog volume.

Fog Volume Entity Setup

With the introduction of control over the density noise, then some interesting shapes can be created within the fog volume entity. Below is a starting guide on how to configure the various parameters to achieve a fog bank effect.

  1. To begin with, setup a large volume (50m in XYZ), add some color, increase the wind influence (5) and ramp up the Global Density to a high value (100) - this will make it easier to see what you are doing when you are changing the various parameters.



  2. Using the DensityNoiseOffset slider, reduce the value down into the negative range (-1.2). This will add noise into the volume and break up its solid shape into patches.



  3. Next adjust the DensityNoiseScale slider (default 1). This will define the thickness of the individual patches of fog (referred to here as clouds), or if you look at it from the other direction it will define how big the spaces are in-between each cloud. Reducing the value to (0.5) will thin out the cloud density and increase the spacing between each cloud.
    DensityNoiseOffset and DensityNoiseScale work closely together, so adjusting one value usually means that the other will require a tweak to achieve the desired result.



  4. Adjusting the DensityNoiseFrequency allows you to define how many fog patches you want. In our example we have increased the Z value from 10 to 100. This creates a layered effect within the volume simulating different fog patches stacked on top of each other. Adding higher values in X & Y would mean there would be more individual fog patches within the volume.
    Having variations within the XYZ values will randomly breakup the fog patches into random sizes.



  5. Modifying the DensityNoiseTimeFrequency allows the individual fog patches to morph into different shapes during the course of their lifetime. Keep this value low (0.2) otherwise they will morph too quickly and will look very unnatural. (This is hard to represent in a static picture, so for consistency we have used a higher value (1) for the screenshot below). .



  6. Final result. Check the checkbox UseGlobalFogColor (doing so helps to achieve more natural blending in the scene and overrides the red colored fog - you should default the fog back to white). The screenshot below represents standing within the fog volume, looking horizontally which helps show how the additional values in DensityNoiseFrequency generate the various fog patches.

    Note: In order for the screenshot below to demonstrate the final result it was necessary for us to have a high fog density setting. During production you would not have the fog density set so high (normal levels used in production settings are in the range of 1-3), this ensures the fog effect you are trying to create is subtle/lifelike for e.g. like you would see around lakes or rivers - this does of course depend on how thick you want your fog volume.




Flowgraph

The fog volume can be controlled through Flowgraph to modify the parameters at run-time.

InputDescription
DensityControls the density of the fog volume entity. 0 -> 100
DensityNoiseOffsetOffsets the noise value for the density. Range -2 -> +2
DensityNoiseScaleScales the noise value for the density. 0 -> 10
WindInfluenceControls the influence of the global wind upon a fog volume. 0 -> 20
EnabledBoolean. Controls the on/off state of the entity.
OutputDescription
EnabledOutputs the on/off state of the entity.

Particle

You can put a particle emitter in your level to add a fog density to that area.

The following parameters found in the "Advanced" group of the Particle Editor window have been added for the control of fog density.

ParameterDescription
Volume FogEnables fog density injection.
Volume ThicknessAdjusts volume thickness.

The following parameters also affect fog density.

  • Texture
  • Alpha
  • Alpha Clip
  • Size
  • Fill Rate Cost
  • Plane Align Blend Distance
Tessellation Parameter

NOTE: Tessellation parameter is not supported.

Light Entity

Light entity has three parameters relating to Volumetric Fog.

ParameterDescription
VolumetricFogEnables the light to affect the Volumetric Fog.
AffectsVolumetricFogOnlyEnables the light to only affect the Volumetric Fog and not to affect meshes etc.
FogRadialLobeAdjusts the blend ratio of the main radial lobe (parallel to the eye ray) and side radial lobe (perpendicular to the eye ray). The direction of the main radial lobe depends on the Anisotropic parameter value used (found in the Time of Day dialog window).

On:

Off:

Notes

  • Check that r_DeferredShadingTiled is set to greater than 0 - usually it is set to 1 or 2. (Default on PC is 2). This is required in order to run voxel-based Volumetric Fog as it shares internal data structures.
  • Using Ramp Start and Ramp End in the "Time of Day" dialog causes performance issues (around 0.3ms on XBoxOne). Therefore, stick to default values whenever possible.
  • PlanarLight with enabled AmbientLight parameter is supported, however PlanarLight with disabled AmbientLight is not currently supported.
  • Large values for Range in the "Time of Day" dialog window are prone to causing fog flicker and light leaking behind a wall, unless that is, the r_VolumetricFogTexDepth is adjusted accordingly - the default settings are; r_VolumetricFogTexDepth=32 for Range=64. If you want to use larger ranges such as Range=256 and with same visual quality, then you need to set r_VolumetricFogTexDepth=64. When Range=1024 is used, then r_VolumetricFogTexDepth=128 should be used.
Ranger_VolumetricFogTexDepth
6432
25664
1024128

Console Variables

CVarDescriptionValues
e_VolumetricFogToggles Volumetric Fog on and off

0 = off, 1 = on.

r_VolumetricFogTexScaleAdjusts the internal volume texture width and height. Screen resolution divided by this factor is applied to both.

This value should be more than or at least equal to 2.

r_VolumetricFogTexDepthAdjusts the internal volume texture depth.

This value should be multiples of 4, but less than 252.

r_VolumetricFogReprojectionBlendFactorAdjusts the blending factor of the temporal re-projection filter. Higher values cause less flicker, but more ghosting.

0 = temporal re-projecton off.

r_VolumetricFogReprojectionModeSets the mode of ghost reduction for the temporal re-projection filter.

0 = Conservative Mode. Ghost artifact appears when a light moves, but there is less flicker than in the Advanced Mode.

1 = Advanced Mode. Less ghost artifact but slightly more flicker than in the Conservative Mode.

r_VolumetricFogSampleAdjusts the number of sample points.

0 = 1 sample point in a voxel.

1 = 2 sample points in a voxel.

2 = 4 sample points in a voxel.

r_VolumetricFogShadowAdjusts the shadow sample count per sample point.

0 = 1 shadow sample per sample point.

1 = 2 shadow samples per sample point.

2 = 3 shadow samples per sample point.

3 = 4 shadow samples per sample point.

r_VolumetricFogDownscaledSunShadowEnables replacing sun shadow maps with downscaled shadow maps or static shadow map if possible. This reduces Volumetric Fog flicker for sun shadow.

0 = disabled.

1 = replace first and second cascades with downscaled shadow maps. Others are replaced with static shadow map if possible.

2 = replace first, second, and third cascades with downscaled shadow maps. Others are replaced with static shadow map if possible.

r_VolumetricFogDownscaledSunShadowRatioSets downscale ratio for sun shadow maps.

0 = 1/4 downscaled sun shadow maps.

1 = 1/8 downscaled sun shadow maps.

2 = 1/16 downscaled sun shadow maps.

r_VolumetricFogMinimumLightBulbSizeAdjusts the minimum size threshold for light attenuation bulb size for voxel-based Volumetric Fog. NOTE: Small bulb size causes light flicker.

An acceptable value is between 0 to 2. Default setting is 0.4.