r.Lumen.Visualize.IndirectDiffuse
r.Lumen.Visualize.IndirectDiffuse
#Overview
name: r.Lumen.Visualize.IndirectDiffuse
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Visualize Lumen Indirect Diffuse.
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Lumen.Visualize.IndirectDiffuse is to enable visualization of Lumen’s indirect diffuse lighting. This setting variable is primarily used for debugging and visual inspection of the Lumen global illumination system in Unreal Engine 5.
The Lumen subsystem within Unreal Engine’s rendering system relies on this setting variable. It is specifically used in the indirect lighting and screen probe tracing components of Lumen.
The value of this variable is set through the console variable system, as indicated by the FAutoConsoleVariableRef declaration. It can be changed at runtime using console commands or through engine configuration files.
This variable interacts with several other variables and systems:
- It affects the behavior of screen probe tracing in LumenScreenProbeTracing.cpp.
- It influences the rendering of diffuse indirect lighting and ambient occlusion in IndirectLightRendering.cpp.
- It impacts the rendering of deferred reflections and sky lighting.
Developers should be aware that:
- When this variable is set to a non-zero value, it may disable certain Lumen features like async compute for diffuse indirect lighting.
- It can affect performance, as it may cause additional visualization passes to be executed.
- It’s primarily intended for debugging and should typically be set to 0 in production builds.
Best practices when using this variable include:
- Use it temporarily for debugging indirect lighting issues.
- Remember to disable it (set to 0) when not actively debugging to avoid performance overhead.
- Combine it with other Lumen visualization tools for comprehensive debugging.
The associated variable GLumenVisualizeIndirectDiffuse serves as the internal representation of the console variable. It’s used throughout the codebase to check the current state of the visualization setting. The same considerations and best practices apply to this internal variable as to the console variable itself.
#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:60
Scope: file
Source code excerpt:
int32 GLumenVisualizeIndirectDiffuse = 0;
FAutoConsoleVariableRef CVarLumenVisualizeIndirectDiffuse(
TEXT("r.Lumen.Visualize.IndirectDiffuse"),
GLumenVisualizeIndirectDiffuse,
TEXT("Visualize Lumen Indirect Diffuse."),
ECVF_RenderThreadSafe
);
int32 GVisualizeLumenSceneTraceMeshSDFs = 1;
#Associated Variable and Callsites
This variable is associated with another variable named GLumenVisualizeIndirectDiffuse
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:869
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::DispatchAsyncLumenIndirectLightingWork
Source code excerpt:
const bool bAsyncComputeDiffuseIndirect = LumenDiffuseIndirect::UseAsyncCompute(ViewFamily);
const bool bAsyncComputeReflections = LumenReflections::UseAsyncCompute(ViewFamily);
extern int32 GLumenVisualizeIndirectDiffuse;
extern int32 GLumenScreenProbeTemporalFilter;
extern FLumenGatherCvarState GLumenGatherCvars;
if (!Lumen::UseAsyncCompute(ViewFamily)
|| !bAsyncComputeDiffuseIndirect
|| GLumenVisualizeIndirectDiffuse
|| ViewFamily.EngineShowFlags.VisualizeLightCulling)
{
return;
}
// Decals may modify GBuffers so they need to be done first. Can decals read velocities and/or custom depth? If so, they need to be rendered earlier too.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:950
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderDiffuseIndirectAndAmbientOcclusion
Source code excerpt:
using namespace HybridIndirectLighting;
extern int32 GLumenVisualizeIndirectDiffuse;
if ((GLumenVisualizeIndirectDiffuse != 0) != bIsVisualizePass
|| ViewFamily.EngineShowFlags.VisualizeLightCulling)
{
return;
}
TRACE_CPUPROFILER_EVENT_SCOPE(FDeferredShadingSceneRenderer::RenderDiffuseIndirectAndAmbientOcclusion);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:1908
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderDeferredReflectionsAndSkyLighting
Source code excerpt:
TArray<FRDGTextureRef>& DynamicBentNormalAOTextures)
{
extern int32 GLumenVisualizeIndirectDiffuse;
if (ViewFamily.EngineShowFlags.VisualizeLightCulling
|| ViewFamily.EngineShowFlags.RayTracingDebug
|| ViewFamily.EngineShowFlags.PathTracing
|| !ViewFamily.EngineShowFlags.Lighting
|| GLumenVisualizeIndirectDiffuse != 0)
{
return;
}
bool bReflectionCapture = false;
for (int32 ViewIndex = 0, Num = Views.Num(); ViewIndex < Num; ViewIndex++)
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenScreenProbeTracing.cpp:673
Scope (from outer to inner):
file
function void TraceScreenProbes
Source code excerpt:
SetupLumenDiffuseTracingParameters(View, IndirectTracingParameters);
extern int32 GLumenVisualizeIndirectDiffuse;
const bool bTraceScreen = View.PrevViewInfo.ScreenSpaceRayTracingInput.IsValid()
&& GLumenScreenProbeGatherScreenTraces != 0
&& GLumenVisualizeIndirectDiffuse == 0
&& View.Family->EngineShowFlags.LumenScreenTraces
&& View.FinalPostProcessSettings.LumenFinalGatherScreenTraces;
if (bTraceScreen)
{
auto TraceScreen = [&](bool bTraceLightSamples)
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualize.cpp:58
Scope: file
Source code excerpt:
);
int32 GLumenVisualizeIndirectDiffuse = 0;
FAutoConsoleVariableRef CVarLumenVisualizeIndirectDiffuse(
TEXT("r.Lumen.Visualize.IndirectDiffuse"),
GLumenVisualizeIndirectDiffuse,
TEXT("Visualize Lumen Indirect Diffuse."),
ECVF_RenderThreadSafe
);
int32 GVisualizeLumenSceneTraceMeshSDFs = 1;
FAutoConsoleVariableRef CVarVisualizeLumenSceneTraceMeshSDFs(