r.Lumen.Visualize.MaxMeshSDFTraceDistance
r.Lumen.Visualize.MaxMeshSDFTraceDistance
#Overview
name: r.Lumen.Visualize.MaxMeshSDFTraceDistance
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Max trace distance for Lumen scene visualization rays. Values below 0 will automatically derrive this from cone angle.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Lumen.Visualize.MaxMeshSDFTraceDistance
is to control the maximum trace distance for Lumen scene visualization rays in Unreal Engine 5’s rendering system. This variable is specifically used for visualizing and debugging the Lumen global illumination system.
This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically within the Lumen visualization subsystem. It’s part of the engine’s advanced rendering features and is used for development and debugging purposes.
The value of this variable is set through the Unreal Engine console system. It’s defined as a console variable (cvar) using FAutoConsoleVariableRef
, which allows it to be changed at runtime through console commands or configuration files.
The associated variable GVisualizeLumenSceneMaxMeshSDFTraceDistance
directly interacts with this console variable. They share the same value, with GVisualizeLumenSceneMaxMeshSDFTraceDistance
being the actual variable used in the code to store and access the value.
Developers must be aware that:
- Values below 0 will automatically derive the max trace distance from the cone angle.
- This variable is render thread safe, meaning it can be safely modified during rendering operations.
- For orthographic projections, there’s a special override mechanism that can be activated using another console variable (
r.Lumen.Ortho.OverrideMeshDFTraceDistances
).
Best practices when using this variable include:
- Use it primarily for debugging and visualization purposes, not for final production settings.
- Be cautious when setting very large values, as it might impact performance.
- When working with orthographic views, consider the interaction with the orthographic override setting.
Regarding the associated variable GVisualizeLumenSceneMaxMeshSDFTraceDistance
:
- Its purpose is to store the actual value used in the code for the maximum mesh SDF trace distance in Lumen scene visualization.
- It’s used directly in the
SetupVisualizeParameters
function to determine theMaxMeshSDFTraceDistance
. - The value is checked against 0.0f to determine whether to use the set value or
FLT_MAX
. - For orthographic projections, its value might be overridden based on the view’s orthographic dimensions.
Developers should be aware that modifying GVisualizeLumenSceneMaxMeshSDFTraceDistance
directly in code is not recommended. Instead, they should use the console variable r.Lumen.Visualize.MaxMeshSDFTraceDistance
to ensure proper synchronization and thread-safety.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualize.cpp:76
Scope: file
Source code excerpt:
float GVisualizeLumenSceneMaxMeshSDFTraceDistance = -1.0f;
FAutoConsoleVariableRef CVarVisualizeLumenSceneCardMaxTraceDistance(
TEXT("r.Lumen.Visualize.MaxMeshSDFTraceDistance"),
GVisualizeLumenSceneMaxMeshSDFTraceDistance,
TEXT("Max trace distance for Lumen scene visualization rays. Values below 0 will automatically derrive this from cone angle."),
ECVF_RenderThreadSafe
);
int32 GVisualizeLumenSceneHiResSurface = 1;
#Associated Variable and Callsites
This variable is associated with another variable named GVisualizeLumenSceneMaxMeshSDFTraceDistance
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualize.cpp:74
Scope: file
Source code excerpt:
);
float GVisualizeLumenSceneMaxMeshSDFTraceDistance = -1.0f;
FAutoConsoleVariableRef CVarVisualizeLumenSceneCardMaxTraceDistance(
TEXT("r.Lumen.Visualize.MaxMeshSDFTraceDistance"),
GVisualizeLumenSceneMaxMeshSDFTraceDistance,
TEXT("Max trace distance for Lumen scene visualization rays. Values below 0 will automatically derrive this from cone angle."),
ECVF_RenderThreadSafe
);
int32 GVisualizeLumenSceneHiResSurface = 1;
FAutoConsoleVariableRef CVarVisualizeLumenSceneHiResSurface(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualize.cpp:622
Scope (from outer to inner):
file
function void SetupVisualizeParameters
Source code excerpt:
FLumenVisualizeSceneSoftwareRayTracingParameters& VisualizeParameters)
{
float MaxMeshSDFTraceDistance = GVisualizeLumenSceneMaxMeshSDFTraceDistance >= 0.0f ? GVisualizeLumenSceneMaxMeshSDFTraceDistance : FLT_MAX;
if (!View.IsPerspectiveProjection())
{
const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Lumen.Ortho.OverrideMeshDFTraceDistances"));
if (CVar && CVar->GetValueOnRenderThread() > 0)
{
MaxMeshSDFTraceDistance = View.ViewMatrices.GetOrthoDimensions().GetMax();