UDN
Search public documentation
FogVolumes
Fog Volumes
Document Summary: This document describes how to use fog volumes, best practices and limitations. Document Changelog: Created by Daniel Wright. Last Update: - WyethJohnson - 11 Feb 2008.Versions
Fog Volumes were introduced in QA_APPROVED_BUILD_MAR_2007. Support for translucency fogged by fog volumes was added soon after and is in QA_APPROVED_BUILD_APRIL_2007. Particle fogging was enabled in QA_APPROVED_BUILD_MAY_2007. The constant height density function was also removed in this build, because the same functionality is available through a constant density function with a clipping mesh. This reduces the number of compiled shaders and is actually more efficient.Quick setup
- Place a closed static mesh
- Place a FogVolumeConstantDensityInfo (Found under Generic Browser->Actor Classes->Info->FogVolumeDensityInfo)
- Add the static mesh to the info actor's FogVolumeActors array.
- To do this you first need to open the properties of the FogVolumeConstantDensityInfo you placed, expand DensityComponent
- Click the lock at the top left of the property window
- Select the static mesh in the viewport
- The property window should still show the info actor, since we locked it.
- Click the + to add an entry to the FogVolumeActors array
- Now click the 'use selected actor' button on the new entry.

Figure 1: Set the static mesh in the FogVolumeActors array. At this point the static mesh should be rendered as a fog volume. It has a default fog volume material applied and collision and lighting has been turned off on the static mesh.
What are Fog Volumes?
A Fog Volume essentially consists of 3 things: A density function, a mesh that clips the density function and a material that defines the color of the fog. Fog Volumes are a superset of the functionality available in HeightFog, because they can be bounded by a mesh and handle multiple density functions. Fog Volumes seamlessly handle the camera going inside the volume and opaque objects intersecting the volume.Density Functions
The Fog Density Function defines how thick the fog is in different parts of the world. In UE3 these density functions are represented by FogVolumeDensityInfo actors. One of these must be placed and have Fog Volume Actors assigned to it. Here are the different density functions, in order from least expensive to most.FogVolumeConstantDensityInfo
This is a density function that has the same density everywhere, which is set through the Density variable.
Figure 2: A cube rendered with the constant density function. The location of the fog info actor is irrelevant because the density is constant everywhere.
FogVolumeLinearHalfspaceDensityInfo
This density function is defined by a plane and a linear density coefficient. The halfspace on one side of the plane will be in fog. This plane can be rotated and placed arbitrarily by rotating and moving the info actor. The density in this function increases linearly with the distance from the plane, so the density is 0 on the plane and at a distance of 1 it becomes PlaneDistanceFactor. The linear density ensures that the halfspace never forms a hard edge, even when the camera is in the plane.
Figure 4: The linear halfspace density function bounded by a cube mesh. Density starts at 0 at the plane and increases away from the plane, which is oriented in the xy plane in this example, but can be used in any orientation.
FogVolumeSphericalDensityInfo
The spherical density function has a maximum density of MaxDensity at the center, and the density falls off quadratically to 0 at the radius of the sphere, giving it smooth edges. The center of the sphere is defined by the info actor's position, and scaling the info actor will scale the radius.

Figure 5 & 6: The Spherical density function, which has smooth edges. It is bounded by a mesh which is not visible in Figure 5 because it doesn't clip the sphere. In Figure 6 the mesh clips the sphere. A preview component shows the extent of the sphere in wireframe.
Fog Volume Actor
The fog volume actor is what is actually rendered, and it clips the density function to the interior of the mesh. Any CLOSED static or skeletal mesh will work. This means that any ray cast through the mesh must intersect the same number of frontfaces as backfaces. On Xenon and the shader model 2 PC implementation there is a limit on the number of frontfaces or backfaces that can overlap before artifacts appear. Currently the limit is 4 backfaces overlapping or 4 frontfaces overlapping.Fog Volume Material
The material assigned to the fog volume actor must have these settings:- Lighting model is Unlit
- Blend mode is one of the translucent modes (Translucent, Additive or Modulative)
- There must be an emissive input
- bUsedWithFogVolumes must be checked.

Figure 7: A minimal fog volume material setup. Opacity defaults to 1 so it does not need to be specified. The emissive input of the material is the fog volume color, the opacity input scales the fog contribution, which is calculated from the distance through the fog volume.
Using Textures
Only the backfaces of the fog volume actor are drawn when applying the material, which is necessary so the fog volume will still be drawn when the camera is inside it. This has implications for texturing: the texture will only be applied to the back of the fog volume mesh. See the Volumetric Lighting Guide for volumetric lighting tricks using textures.Interaction with Height Fog
Fog Volumes can be affected by up to 4 layers of height fog. However, the height fog is only calculated on the backface vertices so if there is a big difference between how much height fog is affecting the backfaces and frontfaces of the fog volume, there will be a visible discrepancy. You can reduce this by increasing the tessellation of the fog volume. Intersecting fog volumes are not supported, they will be drawn as if they were completely in front or behind each other.Transparency in Fog Volumes
Fog Volumes are sorted with transparent objects, so they will draw correctly if they are completely in front or behind transparent objects. However, transparent objects that intersect with fog volumes can't be fogged correctly and efficiently on modern hardware, so they are approximated. It is important that you set the FogVolumeDensityInfo's ApproxFogLightColor to approximate the material color! This is the color that the fog volume will apply to intersecting translucent objects. For a FogVolume which does not contribute color to translucency, untick bAffectsTranslucency in the FogVolumeDensityInfo rollout.
Figure 8: Set the ApproxFogLightColor member so that transparent objects intersecting the fog volume will be fogged correctly. Fog on Transparent objects intersecting Fog Volumes has the following limitations:
- Fog is calculated per-vertex. To minimize the resulting artifacts, increase the tessellation of the transparent meshes.
- Fog transitions due to clipping from the fog volume mesh can't be represented. Instead, the axis aligned bounding box of the fog volume mesh is used to clip the fog. Fog transitions from the fog function (ie the sphere edges in the Spherical Density Function) are calculated correctly.
- The most fog interactions that can be approximated on a single transparent object is 4 height fog layers and one fog volume.
- Transparent materials using the modulative blend mode are not fogged at all, by either height fog or fog volumes.
- Transparent materials applied to skinned meshes (Skeletal meshes or Skeletal mesh decals) will not be fogged by fog volumes.