r.HeterogeneousVolumes.ApplyFogInscattering
r.HeterogeneousVolumes.ApplyFogInscattering
#Overview
name: r.HeterogeneousVolumes.ApplyFogInscattering
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Determines the method for applying fog in-scattering (default = 1)\n0: Off\n1: Reference (evaluated per ray-march step)\n2: Stochastic (evaluated once per ray)\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.HeterogeneousVolumes.ApplyFogInscattering is to control the method for applying fog in-scattering in heterogeneous volumes rendering. This setting is part of Unreal Engine 5’s rendering system, specifically focusing on volumetric fog effects.
This setting variable is primarily used in the Renderer module, specifically within the HeterogeneousVolumes subsystem. It’s defined and used in the HeterogeneousVolumes.cpp file, which suggests it’s a core part of the volumetric rendering pipeline.
The value of this variable is set through a console variable (CVar) system, allowing it to be changed at runtime. It’s initialized with a default value of 1, but can be modified through console commands or configuration files.
The variable interacts directly with its associated variable CVarHeterogeneousVolumesApplyFogInscatteringMode. They share the same value and are used interchangeably in the code.
Developers should be aware that this variable accepts three possible values: 0: Turns off fog in-scattering 1: Uses a reference method, evaluating in-scattering per ray-march step (default) 2: Uses a stochastic method, evaluating in-scattering once per ray
When using this variable, best practices include:
- Understanding the performance implications of each mode. The reference method (1) is likely more accurate but potentially more computationally expensive than the stochastic method (2).
- Testing the visual quality and performance impact of each mode in your specific scene.
- Considering the target hardware when choosing a mode, as lower-end devices might benefit from the less intensive stochastic method or turning the effect off entirely.
Regarding the associated variable CVarHeterogeneousVolumesApplyFogInscatteringMode:
The purpose of CVarHeterogeneousVolumesApplyFogInscatteringMode is identical to r.HeterogeneousVolumes.ApplyFogInscattering. It’s the actual console variable implementation that controls the fog in-scattering method.
This variable is used in the Renderer module, specifically in the HeterogeneousVolumes namespace. It’s accessed in the GetApplyFogInscattering() function, which suggests it’s used to determine the fog mode at runtime.
The value is set through the CVar system and can be changed at runtime. It’s initialized with the same default value (1) and description as r.HeterogeneousVolumes.ApplyFogInscattering.
This variable directly interacts with r.HeterogeneousVolumes.ApplyFogInscattering, sharing the same value and purpose.
Developers should be aware that this variable’s value is clamped between 0 and 2 when retrieved, ensuring it always corresponds to a valid fog mode.
Best practices for using this variable include:
- Using the GetApplyFogInscattering() function to retrieve the current fog mode, as it handles the value clamping.
- Being aware that changes to this variable will immediately affect the rendering pipeline on the render thread.
- Considering the impact on other rendering systems when changing this value, as it may affect overall visual coherence and performance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumes.cpp:230
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesApplyFogInscatteringMode(
TEXT("r.HeterogeneousVolumes.ApplyFogInscattering"),
1,
TEXT("Determines the method for applying fog in-scattering (default = 1)\n")
TEXT("0: Off\n")
TEXT("1: Reference (evaluated per ray-march step)\n")
TEXT("2: Stochastic (evaluated once per ray)\n"),
ECVF_RenderThreadSafe
#Associated Variable and Callsites
This variable is associated with another variable named CVarHeterogeneousVolumesApplyFogInscatteringMode
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumes.cpp:229
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesApplyFogInscatteringMode(
TEXT("r.HeterogeneousVolumes.ApplyFogInscattering"),
1,
TEXT("Determines the method for applying fog in-scattering (default = 1)\n")
TEXT("0: Off\n")
TEXT("1: Reference (evaluated per ray-march step)\n")
TEXT("2: Stochastic (evaluated once per ray)\n"),
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumes.cpp:498
Scope (from outer to inner):
file
namespace HeterogeneousVolumes
function EFogMode GetApplyFogInscattering
Source code excerpt:
EFogMode GetApplyFogInscattering()
{
return static_cast<EFogMode>(FMath::Clamp(CVarHeterogeneousVolumesApplyFogInscatteringMode.GetValueOnRenderThread(), 0, 2));
}
bool ShouldWriteVelocity()
{
return CVarHeterogeneousVolumesVelocity.GetValueOnRenderThread() != 0;
}