r.Lumen.Reflections.Temporal.MaxRayDirections
r.Lumen.Reflections.Temporal.MaxRayDirections
#Overview
name: r.Lumen.Reflections.Temporal.MaxRayDirections
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Number of possible random directions per pixel. Should be tweaked based on MaxFramesAccumulated.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Lumen.Reflections.Temporal.MaxRayDirections is to control the number of possible random directions per pixel for Lumen reflections in Unreal Engine 5. This setting is specifically used for the temporal aspect of Lumen reflections, which helps to improve the quality and stability of reflections over time.
This setting is primarily used in the Lumen reflection system, which is part of Unreal Engine 5’s global illumination solution. It’s referenced in the LumenReflections module of the rendering subsystem.
The value of this variable is set through a console variable (CVarLumenReflectionTemporalMaxRayDirections) with a default value of 16. It can be adjusted at runtime or through configuration files.
The variable interacts with the frame index to determine the ray direction for each frame. Specifically, it’s used in the calculation of ReflectionsRayDirectionFrameIndex, which cycles through the possible ray directions over time.
Developers should be aware that this variable affects the trade-off between reflection quality and performance. A higher value will provide more varied reflections over time but may impact performance.
Best practices when using this variable include:
- Adjusting it based on the MaxFramesAccumulated setting, as suggested in the comment.
- Balancing it with other Lumen settings to achieve the desired quality and performance.
- Testing different values to find the optimal setting for your specific scene and performance requirements.
The associated variable CVarLumenReflectionTemporalMaxRayDirections is the actual console variable that controls this setting. It’s defined with the same name as the setting (“r.Lumen.Reflections.Temporal.MaxRayDirections”), a default value of 16, and flags indicating it affects scalability and is render thread safe. This console variable allows for runtime adjustment of the setting, which can be useful for performance tuning and quality adjustments during development or even in shipped games if exposed to end-users.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:119
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarLumenReflectionTemporalMaxRayDirections(
TEXT("r.Lumen.Reflections.Temporal.MaxRayDirections"),
16,
TEXT("Number of possible random directions per pixel. Should be tweaked based on MaxFramesAccumulated."),
ECVF_Scalability | ECVF_RenderThreadSafe);
float GLumenReflectionNeighborhoodClampExpandWithResolveVariance = .1f;
FAutoConsoleVariableRef CVarLumenReflectionNeighborhoodClampExpandWithResolveVariance(
#Associated Variable and Callsites
This variable is associated with another variable named CVarLumenReflectionTemporalMaxRayDirections
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:118
Scope: file
Source code excerpt:
ECVF_Scalability | ECVF_RenderThreadSafe);
TAutoConsoleVariable<int32> CVarLumenReflectionTemporalMaxRayDirections(
TEXT("r.Lumen.Reflections.Temporal.MaxRayDirections"),
16,
TEXT("Number of possible random directions per pixel. Should be tweaked based on MaxFramesAccumulated."),
ECVF_Scalability | ECVF_RenderThreadSafe);
float GLumenReflectionNeighborhoodClampExpandWithResolveVariance = .1f;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:1065
Scope (from outer to inner):
file
function FRDGTextureRef FDeferredShadingSceneRenderer::RenderLumenReflections
Source code excerpt:
ReflectionTracingParameters.ReflectionsStateFrameIndex = StateFrameIndex;
ReflectionTracingParameters.ReflectionsStateFrameIndexMod8 = StateFrameIndex % 8;
ReflectionTracingParameters.ReflectionsRayDirectionFrameIndex = StateFrameIndex % FMath::Clamp(CVarLumenReflectionTemporalMaxRayDirections.GetValueOnRenderThread(), 1, 128);
}
FRDGBufferRef VisualizeTracesData = nullptr;
if (ReflectionPass == ELumenReflectionPass::Opaque)
{