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. 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.
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.
|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.|
|Range||Adjusts the maximum distance of ray-marching Volumetric Fog. The out of range is covered by analytical Volumetric Fog. (Default setting = 64).|
|In-scattering||Adjusts the factor of in-scattering of all participating media.|
|Extinction||Adjusts the factor of extinction of all participating media.|
|Analytical fog visibility||Adjusts the visibility of analytical Volumetric Fog. Where 0 = no analytical Volumetric Fog, 1 = visible analytical Volumetric Fog.|
|Final density clamp||Adjusts 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.
|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 density||Adjusts the global fog density.|
|Ramp start||Specifies the start distance of fog density ramp.|
|Ramp end||Specifies 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 factor||Adjusts 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.
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.
|AffectsThisAreaOnly||Setting to false ensures the FogVolume entity effect occurs in multiple VisAreas and ClipVolumes.|
|DensityNoiseOffset||Offsets the noise value for the density.|
|DensityNoiseScale||Scales the noise value for the density.|
|DensityNoiseTimeFrequency||Controls the time frequency of the noise for the density. High frequencies produce fast changing fog.|
|DensityOffset||Additional controls to the density of the fog volume.|
|FallOffDirLati||Direction of the fall off (latitude). 90 = up|
|FallOffDirLong||Direction of the fall off (longitude). 0 = East (Positive X)|
|FallOffScale||Scales the density distribution along the fall off direction. Higher values will make the fog fall off more rapidly.|
|FallOffShift||Controls how much to shift the fog density along the fall off direction.|
|GlobalDensity||Controls the density of the fog volume.|
|IgnoreVisAreas||Controls whether the FogVolume entity should respond to VisAreas and ClipVolumes.|
|NearCutOff||Stops rendering the volume, depending on the camera distance to the object (m).|
|RampStart||Specifies the start distance of fog density ramp in world units (m).|
|RampEnd||Specifies the end distance of fog density ramp in world units (m).|
|RampInfluence||Controls the influence of fog density ramp.|
|SoftEdges||Specifies a factor that is used to soften the edges of the fog volume when viewed from outside.|
|UseGlobalFogColor||If true, the entities Color property is ignored. Instead, the current global fog color is used.|
|VolumeType||Specifies the volume type. 0 - Ellipsoid, 1 - Cube.|
|WindInfluence||Controls the influence of the global wind upon the fog volume.|
|DensityNoiseFrequency XYZ||Controls the spatial frequency of the noise for the density. High frequencies produce highly detailed fog.|
|Size XYZ||Sets 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.
- 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.
- 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.
- 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.
- 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.
- 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). .
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.
The fog volume can be controlled through Flowgraph to modify the parameters at run-time.
|Density||Controls the density of the fog volume entity. 0 -> 100|
|DensityNoiseOffset||Offsets the noise value for the density. Range -2 -> +2|
|DensityNoiseScale||Scales the noise value for the density. 0 -> 10|
|WindInfluence||Controls the influence of the global wind upon a fog volume. 0 -> 20|
|Enabled||Boolean. Controls the on/off state of the entity.|
|Enabled||Outputs the on/off state of the entity.|
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.
|Volume Fog||Enables fog density injection.|
|Volume Thickness||Adjusts volume thickness.|
The following parameters also affect fog density.
- Alpha Clip
- Fill Rate Cost
- Plane Align Blend Distance
Light entity has three parameters relating to Volumetric Fog.
|VolumetricFog||Enables the light to affect the Volumetric Fog.|
|AffectsVolumetricFogOnly||Enables the light to only affect the Volumetric Fog and not to affect meshes etc.|
|FogRadialLobe||Adjusts 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).|
- 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.
|e_VolumetricFog||Toggles Volumetric Fog on and off|
0 = off, 1 = on.
|r_VolumetricFogTexScale||Adjusts 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_VolumetricFogTexDepth||Adjusts the internal volume texture depth.|
This value should be multiples of 4, but less than 252.
|r_VolumetricFogReprojectionBlendFactor||Adjusts the blending factor of the temporal re-projection filter. Higher values cause less flicker, but more ghosting.|
0 = temporal re-projecton off.
|r_VolumetricFogReprojectionMode||Sets 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_VolumetricFogSample||Adjusts 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_VolumetricFogShadow||Adjusts 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_VolumetricFogDownscaledSunShadow||Enables 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_VolumetricFogDownscaledSunShadowRatio||Sets 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_VolumetricFogMinimumLightBulbSize||Adjusts 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.