Volumetric fog and local volumes
Configure global fog, local mist and negative-density carving in a complete Forward+ scene.
Choose the effect
Volumetric fog makes lighting visible in a participating medium: indoor haze, beams and local clouds. It requires Forward+, an effective Environment and VolumetricFogEnabled=true. FogEnabled controls a separate, regular fog effect and does not enable FogVolume.
For fog throughout visible space, set Environment.VolumetricFogDensity. For a local region, add a FogVolume with a FogMaterial. Global density can remain zero: fog then appears only inside volumes.
Run the complete scene
Download the fog gallery. Requires Reckfell 1.0.0 with the C# SDK and Forward+/Vulkan. Extract the project, open project.reckfell, build C# and run Main.rscene. Geometry, materials and lights are included; no external assets are needed.
The root uses FogGallery3D.cs below and the archive’s CinematicGallery3D.cs base class. Before running, select exported Preview: Clear, Global, Local or Carve. To switch from running code, call SetPreview(mode) after _Ready: changing Preview during play alone does not apply settings.
| Preview | Global density | Local volume | Result |
|---|---|---|---|
| Clear | 0 | hidden | baseline frame without fog density |
| Global | 0.02 | hidden | haze through the gallery’s depth |
| Local | 0 | Density=0.08 | fog around the central installation |
| Carve | 0.02 | Density=-0.12 | local reduction of global fog |
FogGallery3D.cs
using Reckfell;
public partial class FogGallery3D : CinematicGallery3D
{
public enum FogPreview { Clear, Global, Local, Carve }
[Export] public FogPreview Preview { get; set; } = FogPreview.Local;
public FogVolume Mist { get; private set; } = null!;
public FogMaterial MistMaterial { get; private set; } = null!;
public override void _Ready()
{
base._Ready();
MistMaterial = new FogMaterial
{
Density = 0.08f, Albedo = new Color(0.65f, 0.76f, 0.9f),
Emission = Colors.Black, HeightFalloff = 0, EdgeFade = 0.5f
};
Mist = new FogVolume
{
Position = new Vector3(0, 2.6f, -10), Size = new Vector3(10, 5, 10),
Shape = RenderingServer.FogVolumeShape.Box, Material = MistMaterial
};
AddChild(Mist);
SetPreview(Preview);
}
// Call after _Ready. Editing Preview during play does not call this method.
public void SetPreview(FogPreview mode)
{
var env = GalleryEnvironment;
env.FogEnabled = false;
env.VolumetricFogEnabled = true;
env.VolumetricFogLength = 60;
env.VolumetricFogDensity = mode is FogPreview.Global or FogPreview.Carve ? 0.02f : 0;
env.VolumetricFogAlbedo = new Color(0.62f, 0.69f, 0.78f);
env.VolumetricFogEmission = Colors.Black;
env.VolumetricFogAnisotropy = 0.3f;
env.VolumetricFogTemporalReprojectionEnabled = true;
env.VolumetricFogTemporalReprojectionAmount = 0.9f;
Mist.Visible = mode is FogPreview.Local or FogPreview.Carve;
MistMaterial.Density = mode == FogPreview.Carve ? -0.12f : 0.08f;
}
}Global fog
Raise density gradually: excessive density hides geometry and turns lights into bright patches. Albedo controls the medium’s light scattering; lighting also affects the final color. Emission adds the fog’s own glow but does not create a Light3D for neighboring meshes.
VolumetricFogLength=60 limits fog calculation distance, not camera distance. Increasing length with the same volume buffer spreads its detail over more space. First limit length to the required region, then select fog resolution for the target scene.
Local region
The example FogVolume is at (0, 2.6, -10), Size=(10, 5, 10), Shape=Box. Size contains full axis dimensions, not half-extents. Position and transform place the region; HeightFalloff reduces density upward along world Y relative to the volume position. EdgeFade softens the shape boundary. RenderingServer.FogVolumeShape provides other shapes; World acts globally without Size bounds.
Assign FogMaterial or ShaderMaterial with shader_type fog. StandardMaterial3D describes a mesh surface. If several FogVolume instances share a FogMaterial, edits affect every use of that resource; create separate materials for independent settings.
Native checks confirm that Density=0 removes the local contribution, moving the volume outside the view removes local mist, and VolumetricFogEnabled=false disables the local volume too. Zero global density alone does not disable local volumes.
Reduce fog in a region
Negative FogMaterial.Density reduces existing density inside the shape. It does not make geometry transparent or disable physics. In Carve mode, the same Box partially clears global fog. Density along the rest of the camera-to-object path remains: local carving does not guarantee a completely clear view through the scene.
Diagnose artifacts
| Problem | What to check |
|---|---|
| FogVolume is invisible | Forward+, effective Environment, VolumetricFogEnabled, Material, position, Size and Density |
| Fog remains after Environment density becomes 0 | Local FogVolume instances still add density |
| WorldEnvironment edits have no effect | The active Camera3D Environment can override the world environment |
| Stepped or coarse beams | Reduce VolumetricFogLength; then assess volume_size/volume_depth and cost |
| Moving lights leave trails | Check temporal reprojection; lower its contribution or compare with it disabled |
| Disabling reprojection introduces noise | History accumulation is traded for the current frame; check movement and the target GPU |
| Material edits affect other regions | The volumes share one FogMaterial resource |
Change one parameter at a time when diagnosing. The example enables temporal reprojection with Amount=0.9; a static frame does not establish freedom from motion trails.
Figures use the current local 1.0.0 runtime in Forward+/Vulkan: 2560×1440, internal scale 1.5, MSAA 8×, TAA, identical camera and exposure. This profile serves high-quality illustrations rather than mandatory game settings. Verification covers the stated density and volume changes; animated 3D textures, custom fog shaders and motion behavior need separate validation.
FogVolume API · FogMaterial API · Environment and postprocessing