r.LocalFogVolume.MaxDensityIntoVolumetricFog

r.LocalFogVolume.MaxDensityIntoVolumetricFog

#Overview

name: r.LocalFogVolume.MaxDensityIntoVolumetricFog

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.MaxDensityIntoVolumetricFog is to control the maximum density of local fog volumes when they interact with volumetric fog in the rendering system. This setting is specifically designed to address visual artifacts that can occur due to high density in the bottom part of local fog volumes.

This setting variable is primarily used by the Renderer module of Unreal Engine, specifically in the local fog volume rendering subsystem. It’s part of the engine’s advanced rendering features that handle atmospheric effects.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0.01f, but can be changed at runtime through console commands or project settings.

The associated variable CVarLocalFogVolumeMaxDensityIntoVolumetricFog directly interacts with r.LocalFogVolume.MaxDensityIntoVolumetricFog. They share the same value and purpose.

Developers must be aware that this variable affects the visual quality and performance of fog rendering. Setting it too high might lead to visual artifacts, while setting it too low might reduce the visual impact of local fog volumes.

Best practices when using this variable include:

  1. Start with the default value (0.01f) and adjust gradually.
  2. Test in various lighting conditions and environments to ensure consistent visual quality.
  3. Be mindful of performance impacts when adjusting this value, especially on lower-end hardware.
  4. Use in conjunction with other fog and volumetric rendering settings for best results.

Regarding the associated variable CVarLocalFogVolumeMaxDensityIntoVolumetricFog:

The purpose of CVarLocalFogVolumeMaxDensityIntoVolumetricFog is identical to r.LocalFogVolume.MaxDensityIntoVolumetricFog. It’s the internal representation of the console variable in the C++ code.

This variable is used directly in the Renderer module, specifically in the LocalFogVolumeRendering.cpp file. It’s accessed through the GetLocalFogVolumeMaxDensityIntoVolumetricFog() function, which ensures the value is always non-negative.

The value of this variable is set when the engine initializes the console variable system, but can be changed at runtime.

Developers should be aware that this variable is thread-safe for render thread access (ECVF_RenderThreadSafe flag). Any changes to this variable will affect rendering in real-time.

Best practices for using CVarLocalFogVolumeMaxDensityIntoVolumetricFog include:

  1. Access the value using the provided getter function (GetLocalFogVolumeMaxDensityIntoVolumetricFog()) rather than directly.
  2. Be cautious when modifying this value during runtime, as it can have immediate effects on rendering.
  3. Consider exposing this setting to artists or level designers through a user-friendly interface if frequent adjustments are needed.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


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."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarLocalFogVolumeApplyOnTranslucent(
	TEXT("r.LocalFogVolume.ApplyOnTranslucent"), 0,
	TEXT("Project settings enabling the sampling of local fog volumes on translucent elements."),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	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."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarLocalFogVolumeApplyOnTranslucent(
	TEXT("r.LocalFogVolume.ApplyOnTranslucent"), 0,

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

Scope (from outer to inner):

file
function     static float GetLocalFogVolumeMaxDensityIntoVolumetricFog

Source code excerpt:

static float GetLocalFogVolumeMaxDensityIntoVolumetricFog()
{
	return FMath::Max(0.0f, CVarLocalFogVolumeMaxDensityIntoVolumetricFog.GetValueOnRenderThread());
}

static uint32 GetLocalFogVolumeTileMaxInstanceCount()
{
	// We do not allow more than 256 instances since culled indices might be stored a u8 values.
	return FMath::Max(1u, FMath::Min(256u, (uint32)CVarLocalFogVolumeTileMaxInstanceCount.GetValueOnRenderThread()));