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.
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 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.
Parameter | Description |
---|---|
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 control parameters are found in the "Volumetric Fog" group. The "Volumetric Fog" group can be found in the Time of Day dialog window.
Parameter | Description |
---|---|
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. |
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.
Parameter | Description |
---|---|
Active | On/Off. |
AffectsThisAreaOnly | Setting to false ensures the FogVolume entity effect occurs in multiple VisAreas and ClipVolumes. |
Color | RGB |
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. |
HDRDynamic | Deprecated. |
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. |
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.
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.
Input | Description |
---|---|
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. |
Output | Description |
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.
Parameter | Description |
---|---|
Volume Fog | Enables fog density injection. |
Volume Thickness | Adjusts volume thickness. |
The following parameters also affect fog density.
NOTE: Tessellation parameter is not supported.
Light entity has three parameters relating to Volumetric Fog.
Parameter | Description |
---|---|
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). |
On:
Off:
Range | r_VolumetricFogTexDepth |
---|---|
64 | 32 |
256 | 64 |
1024 | 128 |
CVar | Description | Values |
---|---|---|
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. |