r.ManyLights.Temporal.NeighborhoodClampScale
r.ManyLights.Temporal.NeighborhoodClampScale
#Overview
name: r.ManyLights.Temporal.NeighborhoodClampScale
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Scales how permissive is neighborhood clamp. Higher values cause more ghosting, but allow smoother temporal accumulation.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ManyLights.Temporal.NeighborhoodClampScale is to control the permissiveness of the neighborhood clamp in the Many Lights rendering system of Unreal Engine 5. This setting is specifically used for temporal accumulation in the rendering process.
This setting variable is primarily used by the Many Lights rendering system, which is part of the Renderer module in Unreal Engine 5. Based on the callsites, it’s clear that this variable is utilized within the deferred shading scene renderer, specifically in the RenderManyLights function.
The value of this variable is set as a console variable with a default value of 2.0f. It can be modified at runtime through the console or programmatically.
The associated variable CVarManyLightsTemporalNeighborhoodClampScale interacts directly with r.ManyLights.Temporal.NeighborhoodClampScale, as they share the same value. This variable is used to retrieve the current value of the setting in the rendering code.
Developers must be aware that higher values of this variable will cause more ghosting in the rendered image but allow for smoother temporal accumulation. This trade-off is crucial for balancing visual quality and performance.
Best practices when using this variable include:
- Carefully adjusting the value to find the right balance between ghosting and smooth temporal accumulation for your specific scene.
- Testing the variable’s impact across different types of scenes and lighting conditions.
- Considering the performance implications of different values, especially on lower-end hardware.
Regarding the associated variable CVarManyLightsTemporalNeighborhoodClampScale:
The purpose of CVarManyLightsTemporalNeighborhoodClampScale is to provide a programmatic interface to access and modify the r.ManyLights.Temporal.NeighborhoodClampScale setting within the C++ code of the engine.
This variable is used directly in the Renderer module, specifically in the ManyLights system. It’s accessed in the RenderManyLights function of the FDeferredShadingSceneRenderer class.
The value of this variable is set when the r.ManyLights.Temporal.NeighborhoodClampScale console variable is initialized or modified.
CVarManyLightsTemporalNeighborhoodClampScale interacts directly with the r.ManyLights.Temporal.NeighborhoodClampScale console variable, serving as its C++ representation.
Developers should be aware that this variable is marked with ECVF_Scalability and ECVF_RenderThreadSafe flags, indicating that it’s safe to modify on the render thread and can be used for scalability settings.
Best practices for using this variable include:
- Accessing its value using the GetValueOnRenderThread() method when in render thread context.
- Considering its impact on different hardware configurations due to its scalability nature.
- Using it in conjunction with other Many Lights system parameters for comprehensive control over the rendering process.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:54
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarManyLightsTemporalNeighborhoodClampScale(
TEXT("r.ManyLights.Temporal.NeighborhoodClampScale"),
2.0f,
TEXT("Scales how permissive is neighborhood clamp. Higher values cause more ghosting, but allow smoother temporal accumulation."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarManyLightsSpatial(
#Associated Variable and Callsites
This variable is associated with another variable named CVarManyLightsTemporalNeighborhoodClampScale
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:53
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<float> CVarManyLightsTemporalNeighborhoodClampScale(
TEXT("r.ManyLights.Temporal.NeighborhoodClampScale"),
2.0f,
TEXT("Scales how permissive is neighborhood clamp. Higher values cause more ghosting, but allow smoother temporal accumulation."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:763
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderManyLights
Source code excerpt:
ManyLightsParameters.DownsampledTileDataStride = DownsampledTileDataStride;
ManyLightsParameters.TemporalMaxFramesAccumulated = FMath::Max(CVarManyLightsTemporalMaxFramesAccumulated.GetValueOnRenderThread(), 0.0f);
ManyLightsParameters.TemporalNeighborhoodClampScale = CVarManyLightsTemporalNeighborhoodClampScale.GetValueOnRenderThread();
ManyLightsParameters.TemporalAdvanceFrame = View.ViewState && !View.bStatePrevViewInfoIsReadOnly ? 1 : 0;
ManyLightsParameters.DebugMode = ManyLights::GetDebugMode();
ManyLightsParameters.DebugLightId = INDEX_NONE;
if (bDebug)
{