r.Lumen.DiffuseIndirect.MinTraceDistance
r.Lumen.DiffuseIndirect.MinTraceDistance
#Overview
name: r.Lumen.DiffuseIndirect.MinTraceDistance
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Lumen.DiffuseIndirect.MinTraceDistance is to set the minimum distance for ray tracing in Lumen’s diffuse indirect lighting calculations. This setting is part of Unreal Engine 5’s Lumen global illumination system, specifically for the diffuse indirect lighting component.
This setting variable is primarily used in the Lumen subsystem of Unreal Engine’s rendering module. It’s referenced in the LumenDiffuseIndirect.cpp file, which is part of the Renderer’s private implementation.
The value of this variable is set through the Unreal Engine’s console variable system. It’s defined as an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands or configuration files.
The r.Lumen.DiffuseIndirect.MinTraceDistance variable interacts directly with the GLumenDiffuseMinTraceDistance variable. They share the same value, with GLumenDiffuseMinTraceDistance being the actual float variable used in the code.
Developers should be aware that this variable affects the performance and quality of Lumen’s diffuse indirect lighting. Setting it too low might introduce artifacts, while setting it too high might miss important short-range lighting interactions.
Best practices when using this variable include:
- Adjusting it based on the scale of your scene.
- Balancing it with other Lumen settings for optimal performance and quality.
- Testing different values to find the best trade-off between performance and visual quality for your specific use case.
Regarding the associated variable GLumenDiffuseMinTraceDistance:
The purpose of GLumenDiffuseMinTraceDistance is to store the actual value used in the Lumen diffuse indirect lighting calculations. It’s the C++ variable that directly controls the minimum trace distance in the rendering code.
This variable is used in the Lumen subsystem of the rendering module, specifically in the diffuse indirect lighting calculations.
The value of GLumenDiffuseMinTraceDistance is set by the console variable system through r.Lumen.DiffuseIndirect.MinTraceDistance.
It interacts with other Lumen parameters in the SetupLumenDiffuseTracingParameters and SetupLumenDiffuseTracingParametersForProbe functions.
Developers should be aware that this variable is clamped between 0.01 and 1000.0 units when used in calculations, which prevents extreme values that could cause issues.
Best practices include:
- Avoiding direct modification of GLumenDiffuseMinTraceDistance in code, instead use the console variable for consistency.
- Considering the impact on both regular scene rendering and probe rendering, as it’s used in both contexts.
- Balancing this value with other Lumen parameters for optimal results.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenDiffuseIndirect.cpp:56
Scope: file
Source code excerpt:
float GLumenDiffuseMinTraceDistance = 0;
FAutoConsoleVariableRef CVarLumenDiffuseMinTraceDistance(
TEXT("r.Lumen.DiffuseIndirect.MinTraceDistance"),
GLumenDiffuseMinTraceDistance,
TEXT("."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
FAutoConsoleVariableRef CVarLumenDiffuseSurfaceBias(
#Associated Variable and Callsites
This variable is associated with another variable named GLumenDiffuseMinTraceDistance
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenDiffuseIndirect.cpp:54
Scope: file
Source code excerpt:
);
float GLumenDiffuseMinTraceDistance = 0;
FAutoConsoleVariableRef CVarLumenDiffuseMinTraceDistance(
TEXT("r.Lumen.DiffuseIndirect.MinTraceDistance"),
GLumenDiffuseMinTraceDistance,
TEXT("."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
FAutoConsoleVariableRef CVarLumenDiffuseSurfaceBias(
TEXT("r.Lumen.DiffuseIndirect.SurfaceBias"),
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenDiffuseIndirect.cpp:303
Scope (from outer to inner):
file
function void SetupLumenDiffuseTracingParameters
Source code excerpt:
OutParameters.MinSampleRadius = FMath::Clamp(GLumenDiffuseMinSampleRadius, .01f, 100.0f);
OutParameters.MinTraceDistance = FMath::Clamp(GLumenDiffuseMinTraceDistance, .01f, 1000.0f);
OutParameters.MaxTraceDistance = Lumen::GetMaxTraceDistance(View);
if (!View.IsPerspectiveProjection() && CVarOrthoOverrideMeshDFTraceDistances.GetValueOnAnyThread())
{
float TraceSDFDistance = FMath::Clamp(View.ViewMatrices.GetOrthoDimensions().GetMax(), OutParameters.MinTraceDistance, OutParameters.MaxTraceDistance);
OutParameters.MaxMeshSDFTraceDistance = TraceSDFDistance;
OutParameters.CardTraceEndDistanceFromCamera = FMath::Max(GDiffuseCardTraceEndDistanceFromCamera, TraceSDFDistance);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenDiffuseIndirect.cpp:333
Scope (from outer to inner):
file
function void SetupLumenDiffuseTracingParametersForProbe
Source code excerpt:
// Probe tracing doesn't have surface bias, but should bias MinTraceDistance due to the mesh SDF world space error
OutParameters.SurfaceBias = 0.0f;
OutParameters.MinTraceDistance = FMath::Clamp(FMath::Max(GLumenGatherCvars.SurfaceBias, GLumenDiffuseMinTraceDistance), .01f, 1000.0f);
if (DiffuseConeHalfAngle >= 0.0f)
{
OutParameters.DiffuseConeHalfAngle = DiffuseConeHalfAngle;
OutParameters.TanDiffuseConeHalfAngle = FMath::Tan(DiffuseConeHalfAngle);
}