r.Lumen.Reflections.SampleSceneColorAtHit
r.Lumen.Reflections.SampleSceneColorAtHit
#Overview
name: r.Lumen.Reflections.SampleSceneColorAtHit
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to sample SceneColor on reflection ray hits (both SWRT and HWRT). Useful for hiding areas where Screen Traces gave up when they went behind a foreground object. 0 - Disable. 1 - Enable only when screen space traces are enabled. 2 - Always enable.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Lumen.Reflections.SampleSceneColorAtHit is to control whether to sample the scene color at reflection ray hit points in Unreal Engine 5’s Lumen global illumination system. This setting is specifically for the rendering system, particularly the Lumen reflections component.
This setting variable is primarily used in the Lumen reflection tracing subsystem of Unreal Engine 5’s rendering module. It’s referenced in the LumenReflectionTracing.cpp file, which is part of the Renderer module.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 and can be changed at runtime using console commands or through project settings.
The variable interacts closely with GLumenReflectionsSampleSceneColorAtHit, which is the associated C++ variable that directly holds the value set by the console variable. It also interacts with other Lumen reflection settings, such as GLumenReflectionScreenTraces and View.Family->EngineShowFlags.LumenScreenTraces.
Developers must be aware that this variable has three possible states: 0 - Disable sampling of SceneColor at reflection ray hits 1 - Enable sampling only when screen space traces are enabled 2 - Always enable sampling
Best practices when using this variable include:
- Use it in conjunction with other Lumen reflection settings for optimal results.
- Consider performance implications when enabling this feature, especially in performance-critical scenarios.
- Test different settings to find the best balance between visual quality and performance for your specific use case.
Regarding the associated variable GLumenReflectionsSampleSceneColorAtHit:
This is the actual C++ variable that stores the value set by the r.Lumen.Reflections.SampleSceneColorAtHit console variable. It’s used directly in the code to determine whether to sample SceneColor on reflection ray hits.
The purpose of this variable is to provide a quick, runtime-accessible way to control the SceneColor sampling behavior in the Lumen reflection tracing system.
It’s used in the TraceReflections function to determine if SceneColor sampling should be performed. The logic considers both this variable and whether screen traces are enabled.
Developers should be aware that changes to the console variable will directly affect this C++ variable, and thus the behavior of the reflection tracing system. It’s important to consider the performance and visual implications when modifying this value during development or allowing it to be changed in shipping builds.
Best practices include using this variable in conjunction with other Lumen settings for fine-tuning reflection quality and performance, and thoroughly testing different configurations to ensure optimal results across various scenarios in your game or application.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflectionTracing.cpp:87
Scope: file
Source code excerpt:
int32 GLumenReflectionsSampleSceneColorAtHit = 1;
FAutoConsoleVariableRef CVarLumenReflectionsSampleSceneColorAtHit(
TEXT("r.Lumen.Reflections.SampleSceneColorAtHit"),
GLumenReflectionsSampleSceneColorAtHit,
TEXT("Whether to sample SceneColor on reflection ray hits (both SWRT and HWRT). Useful for hiding areas where Screen Traces gave up when they went behind a foreground object. 0 - Disable. 1 - Enable only when screen space traces are enabled. 2 - Always enable."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
float GLumenReflectionSampleSceneColorRelativeDepthThreshold = .05f;
#Associated Variable and Callsites
This variable is associated with another variable named GLumenReflectionsSampleSceneColorAtHit
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflectionTracing.cpp:85
Scope: file
Source code excerpt:
);
int32 GLumenReflectionsSampleSceneColorAtHit = 1;
FAutoConsoleVariableRef CVarLumenReflectionsSampleSceneColorAtHit(
TEXT("r.Lumen.Reflections.SampleSceneColorAtHit"),
GLumenReflectionsSampleSceneColorAtHit,
TEXT("Whether to sample SceneColor on reflection ray hits (both SWRT and HWRT). Useful for hiding areas where Screen Traces gave up when they went behind a foreground object. 0 - Disable. 1 - Enable only when screen space traces are enabled. 2 - Always enable."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
float GLumenReflectionSampleSceneColorRelativeDepthThreshold = .05f;
FAutoConsoleVariableRef GVarLumenReflectionSampleSceneColorRelativeDepthThreshold(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflectionTracing.cpp:887
Scope (from outer to inner):
file
function void TraceReflections
Source code excerpt:
const bool bScreenTraces = GLumenReflectionScreenTraces != 0 && View.Family->EngineShowFlags.LumenScreenTraces && View.FinalPostProcessSettings.LumenReflectionsScreenTraces;
const bool bSampleSceneColorAtHit = (GLumenReflectionsSampleSceneColorAtHit != 0 && bScreenTraces) || GLumenReflectionsSampleSceneColorAtHit == 2;
const bool bDistantScreenTraces = GLumenReflectionsDistantScreenTraces && bScreenTraces;
if (bScreenTraces)
{
FReflectionTraceScreenTexturesCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FReflectionTraceScreenTexturesCS::FParameters>();