Up to date
This page is up to date for Godot
If you still find outdated information, please open an issue.
Volumetric fog and fog volumes¶
Volumetric fog is only supported in the Clustered Forward rendering backend, not Forward Mobile or Compatibility.
As described in Environment and post-processing, Godot supports various visual effects including two types of fog: traditional (non-volumetric) fog and volumetric fog. Traditional fog affects the entire scene at once and cannot be customized with Fog shaders.
Volumetric fog can be used at the same time as non-volumetric fog if desired.
On this page, you'll learn:
How to set up volumetric fog in Godot.
What fog volumes are and how they differ from "global" volumetric fog.
You can see how volumetric fog works in action using the Volumetric Fog demo project.
Here is a comparison between traditional fog (which does not interact with lighting) and volumetric fog, which is able to interact with lighting:
Volumetric fog properties¶
After enabling volumetric fog in the WorldEnvironment node's Environment resource, you can edit the following properties:
Density: The base exponential density of the volumetric fog. Set this to the lowest density you want to have globally. FogVolumes can be used to add to or subtract from this density in specific areas. A value of
0.0disables global volumetric fog while allowing FogVolumes to display volumetric fog in specific areas. Fog rendering is exponential as in real life.
Albedo: The Color of the volumetric fog when interacting with lights. Mist and fog have an albedo close to white (
Color(1, 1, 1, 1)) while smoke has a darker albedo.
Emission: The emitted light from the volumetric fog. Even with emission, volumetric fog will not cast light onto other surfaces. Emission is useful to establish an ambient color. As the volumetric fog effect uses single-scattering only, fog tends to need a little bit of emission to soften the harsh shadows.
Emission Energy: The brightness of the emitted light from the volumetric fog.
GI Inject: Scales the strength of Global Illumination used in the volumetric fog's albedo color. A value of
0.0means that Global Illumination will not impact the volumetric fog. This has a small performance cost when set above
Anisotropy: The direction of scattered light as it goes through the volumetric fog. A value close to
1.0means almost all light is scattered forward. A value close to
0.0means light is scattered equally in all directions. A value close to
-1.0means light is scattered mostly backward. Fog and mist scatter light slightly forward, while smoke scatters light equally in all directions.
Length: The distance over which the volumetric fog is computed. Increase to compute fog over a greater range, decrease to add more detail when a long range is not needed. For best quality fog, keep this as low as possible.
Detail Spread: The distribution of size down the length of the froxel buffer. A higher value compresses the froxels closer to the camera and places more detail closer to the camera.
Ambient Inject: Scales the strength of ambient light used in the volumetric fog. A value of
0.0means that ambient light will not impact the volumetric fog. This has a small performance cost when set above
Sky Affect: Controls how much volumetric fog should be drawn onto the background sky. If set to
0.0, volumetric fog won't affect sky rendering at all (including FogVolumes).
Two additional properties are offered in the Temporal Reprojection section:
Temporal Reprojection > Enabled: Enables temporal reprojection in the volumetric fog. Temporal reprojection blends the current frame's volumetric fog with the last frame's volumetric fog to smooth out jagged edges. The performance cost is minimal, however it does lead to moving FogVolumes and Light3Ds "ghosting" and leaving a trail behind them. When temporal reprojection is enabled, try to avoid moving FogVolumes or Light3Ds too fast. Short-lived dynamic lighting effects should have Volumetric Fog Energy set to
0.0to avoid ghosting.
Temporal Reprojection > Amount: The amount by which to blend the last frame with the current frame. A higher number results in smoother volumetric fog, but makes "ghosting" much worse. A lower value reduces ghosting but can result in the per-frame temporal jitter becoming visible.
Unlike non-volumetric fog, volumetric fog has a finite range. This means volumetric fog cannot entirely cover a large world, as it will eventually stop being rendered in the distance.
If you wish to hide distant areas from the player, it's recommended to enable both non-volumetric fog and volumetric fog at the same time, and adjust their density accordingly.
Light interaction with volumetric fog¶
To simulate fog light scattering behavior in real life, all light types will interact with volumetric fog. How much each light will affect volumetric fog can be adjusted using the Volumetric Fog Energy property on each light. Enabling shadows on a light will also make those shadows visible on volumetric fog.
If fog light interaction is not desired for artistic reasons, this can be
globally disabled by setting Volumetric Fog > Albedo to a pure black color
in the Environment resource. Fog light interaction can also be disabled for
specific lights by setting its Volumetric Fog Energy to
0. Doing so will
also improve performance slightly by excluding the light from volumetric fog
Using volumetric fog as a volumetric lighting solution¶
While not physically accurate, it is possible to tune volumetric fog's settings to work as volumetric lighting solution. This means that unlit parts of the environment will not be darkened anymore by fog, but light will still be able to make fog brighter in specific areas.
This can be done by setting volumetric fog density to the lowest permitted value
greater than zero (
0.0001), then increasing the Volumetric Fog Energy
property on lights to much higher values than the default to compensate. Values
100000 usually work well for this.
Balancing performance and quality¶
There are a few project settings available to adjust volumetric fog performance and quality:
Rendering > Environment > Volumetric Fog > Volume Size: Base size used to determine size of froxel buffer in the camera X-axis and Y-axis. The final size is scaled by the aspect ratio of the screen, so actual values may differ from what is set. Set a larger size for more detailed fog, set a smaller size for better performance.
Rendering > Environment > Volumetric Fog > Volume Depth: Number of slices to use along the depth of the froxel buffer for volumetric fog. A lower number will be more efficient but may result in artifacts appearing during camera movement.
Rendering > Environment > Volumetric Fog > Use Filter: Enables filtering of the volumetric fog effect prior to integration. This substantially blurs the fog which reduces fine details but also smooths out harsh edges and aliasing artifacts. Disable when more detail is required.
Using fog volumes for local volumetric fog¶
Sometimes, you want fog to be constrained to specific areas. Conversely, you may want to have global volumetric fog but fog should be excluded from certain areas. Both approaches can be followed using FogVolume nodes.
Here's a quick start guide to using FogVolumes:
Make sure Volumetric Fog is enabled in the Environment properties. If global volumetric fog is undesired, set its Density to
Create a FogVolume node.
Assign a new FogMaterial to the FogVolume node's Material property.
In the FogMaterial, set Density to a positive value to increase density within the FogVolume, or a negative value to subtract the density from global volumetric fog.
Configure the FogVolume's extents and shape as needed.
Thin fog volumes may appear to flicker when the camera moves or rotates. This can be alleviated by increasing the Rendering > Environment > Volumetric Fog > Volume Depth project setting (at a performance cost) or by decreasing Length in the Environment volumetric fog properties (at no performance co