r.ManyLights.Spatial.DepthWeightScale
r.ManyLights.Spatial.DepthWeightScale
#Overview
name: r.ManyLights.Spatial.DepthWeightScale
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Scales the depth weight of the spatial filter. Smaller values allow for more sample reuse, but also introduce more bluriness between unrelated surfaces.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ManyLights.Spatial.DepthWeightScale is to control the depth weighting in the spatial filter used in the Many Lights rendering system. This setting variable is part of Unreal Engine 5’s rendering system, specifically the deferred shading and lighting pipeline.
This setting variable is primarily used in the Renderer module, particularly in the Many Lights subsystem. Based on the callsites, it’s evident that this variable is utilized in the deferred shading scene renderer, specifically in the RenderManyLights function.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 10000.0f, but can be changed at runtime through console commands or project settings.
The associated variable CVarManyLightsSpatialDepthWeightScale interacts directly with r.ManyLights.Spatial.DepthWeightScale. They share the same value and purpose.
Developers must be aware that this variable significantly impacts the trade-off between sample reuse and surface detail preservation in the spatial filter. Smaller values allow for more sample reuse, which can improve performance, but at the cost of potentially introducing more blurriness between unrelated surfaces.
Best practices when using this variable include:
- Carefully balancing performance gains against visual quality.
- Testing different values to find the optimal setting for your specific scene and performance requirements.
- Being cautious when dramatically lowering the value, as it may lead to noticeable visual artifacts.
- Considering the impact on different types of scenes and lighting conditions.
Regarding the associated variable CVarManyLightsSpatialDepthWeightScale:
The purpose of CVarManyLightsSpatialDepthWeightScale is identical to r.ManyLights.Spatial.DepthWeightScale. It’s the actual console variable that controls the depth weight scaling in the Many Lights spatial filter.
This variable is used in the Renderer module, specifically in the ManyLights.cpp file. It’s accessed in the RenderManyLights function of the FDeferredShadingSceneRenderer class.
The value is set when the console variable is created, with a default of 10000.0f. It can be modified at runtime through console commands.
CVarManyLightsSpatialDepthWeightScale directly interacts with the r.ManyLights.Spatial.DepthWeightScale setting, as they represent the same value.
Developers should be aware that this is the actual variable used in the rendering code, and changes to it will immediately affect the spatial filter’s behavior.
Best practices for using CVarManyLightsSpatialDepthWeightScale are the same as for r.ManyLights.Spatial.DepthWeightScale, focusing on finding the right balance between performance and visual quality for your specific use case.
#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:68
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarManyLightsSpatialDepthWeightScale(
TEXT("r.ManyLights.Spatial.DepthWeightScale"),
10000.0f,
TEXT("Scales the depth weight of the spatial filter. Smaller values allow for more sample reuse, but also introduce more bluriness between unrelated surfaces."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarManyLightsWaveOps(
#Associated Variable and Callsites
This variable is associated with another variable named CVarManyLightsSpatialDepthWeightScale
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:67
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<float> CVarManyLightsSpatialDepthWeightScale(
TEXT("r.ManyLights.Spatial.DepthWeightScale"),
10000.0f,
TEXT("Scales the depth weight of the spatial filter. Smaller values allow for more sample reuse, but also introduce more bluriness between unrelated surfaces."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:1148
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderManyLights
Source code excerpt:
PassParameters->SpecularLightingAndSecondMomentTexture = SpecularLightingAndSecondMoment;
PassParameters->NumFramesAccumulatedTexture = NumFramesAccumulated;
PassParameters->SpatialFilterDepthWeightScale = CVarManyLightsSpatialDepthWeightScale.GetValueOnRenderThread();
FDenoiserSpatialCS::FPermutationDomain PermutationVector;
PermutationVector.Set<FDenoiserSpatialCS::FSpatialFilter>(CVarManyLightsSpatial.GetValueOnRenderThread() != 0);
PermutationVector.Set<FDenoiserSpatialCS::FDebugMode>(bDebug);
auto ComputeShader = View.ShaderMap->GetShader<FDenoiserSpatialCS>(PermutationVector);