r.LocalFogVolume.RenderIntoVolumetricFog

r.LocalFogVolume.RenderIntoVolumetricFog

#Overview

name: r.LocalFogVolume.RenderIntoVolumetricFog

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.LocalFogVolume.RenderIntoVolumetricFog is to control whether local fog volumes are voxelized into the volumetric fog or remain isolated in the rendering process.

This setting variable is primarily used by the rendering system, specifically in the local fog volume rendering subsystem of Unreal Engine 5. The Renderer module relies on this variable to determine how to handle local fog volumes in relation to the global volumetric fog.

The value of this variable is set through the console variable system (CVarLocalFogVolumeRenderIntoVolumetricFog). It’s initialized with a default value of 1, meaning local fog volumes are voxelized into the volumetric fog by default.

This variable interacts closely with other fog-related variables, particularly CVarLocalFogVolumeMaxDensityIntoVolumetricFog, which controls the maximum density of local fog volumes when they’re integrated into the volumetric fog.

Developers should be aware that changing this variable will significantly impact the visual appearance and performance of fog rendering in their scenes. When set to 0, local fog volumes will remain isolated, which may be desirable in certain scenarios but could lead to visual inconsistencies with the global volumetric fog.

Best practices when using this variable include:

  1. Consider the visual and performance implications before changing the default value.
  2. Test thoroughly in various lighting conditions and scene compositions when modifying this setting.
  3. Use in conjunction with CVarLocalFogVolumeMaxDensityIntoVolumetricFog for fine-tuned control over fog appearance.

Regarding the associated variable CVarLocalFogVolumeRenderIntoVolumetricFog:

This is the actual console variable that controls the r.LocalFogVolume.RenderIntoVolumetricFog setting. It’s an integer variable, where values greater than 0 enable the voxelization of local fog volumes into the volumetric fog.

The variable is used in the ShouldRenderLocalFogVolumeInVolumetricFog function to determine whether local fog volumes should be rendered into the volumetric fog. This function checks if both local fog volume rendering and volumetric fog rendering are enabled for the scene, and then uses the value of CVarLocalFogVolumeRenderIntoVolumetricFog to make the final decision.

Developers should be aware that this variable is marked as ECVF_RenderThreadSafe, meaning it can be safely changed at runtime from the render thread. This allows for dynamic adjustments to fog rendering behavior without requiring a full engine restart.

Best practices for using this variable include:

  1. Use the console command system to adjust this value during development for quick iterations on fog appearance.
  2. Consider exposing this setting in your game’s graphics options menu to allow players to optimize for performance or visual quality.
  3. Monitor performance impacts when enabling this feature, especially in scenes with many local fog volumes.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:28

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarLocalFogVolumeRenderIntoVolumetricFog(
	TEXT("r.LocalFogVolume.RenderIntoVolumetricFog"), 1,
	TEXT("LocalFogVolume are going to be voxelised into the volumetric fog when this is not 0, otherwise it will remain isolated."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarLocalFogVolumeMaxDensityIntoVolumetricFog(
	TEXT("r.LocalFogVolume.MaxDensityIntoVolumetricFog"), 0.01f,
	TEXT("LocalFogVolume height fog mode can become exponentially dense in the bottom part. VolumetricFog temporal reprojection then can leak du to high density. Clamping density is a way to get that visual artefact under control."),

#Associated Variable and Callsites

This variable is associated with another variable named CVarLocalFogVolumeRenderIntoVolumetricFog. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:27

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarLocalFogVolumeRenderIntoVolumetricFog(
	TEXT("r.LocalFogVolume.RenderIntoVolumetricFog"), 1,
	TEXT("LocalFogVolume are going to be voxelised into the volumetric fog when this is not 0, otherwise it will remain isolated."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarLocalFogVolumeMaxDensityIntoVolumetricFog(
	TEXT("r.LocalFogVolume.MaxDensityIntoVolumetricFog"), 0.01f,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:130

Scope (from outer to inner):

file
function     bool ShouldRenderLocalFogVolumeInVolumetricFog

Source code excerpt:

	if (ShouldRenderLocalFogVolume(Scene, SceneViewFamily) && bShouldRenderVolumetricFog)
	{
		return CVarLocalFogVolumeRenderIntoVolumetricFog.GetValueOnRenderThread() > 0;
	}
	return false;
}

float GetLocalFogVolumeGlobalStartDistance()
{