r.Shadow.Virtual.SMRT.MaxSlopeBiasLocal
r.Shadow.Virtual.SMRT.MaxSlopeBiasLocal
#Overview
name: r.Shadow.Virtual.SMRT.MaxSlopeBiasLocal
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Maximum depth slope. Low values produce artifacts if shadow resolution is insufficient. High values can worsen light leaks near occluders and sparkly pixels in shadowed areas.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Virtual.SMRT.MaxSlopeBiasLocal is to control the maximum depth slope in virtual shadow maps. It is a setting used in the rendering system, specifically for shadow rendering using the Virtual Shadow Map (VSM) technique.
This setting variable is primarily used in the Renderer module of Unreal Engine 5, particularly in the Virtual Shadow Maps subsystem. It’s referenced in the VirtualShadowMapProjection.cpp file, which is responsible for handling the projection of virtual shadow maps.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 50.0f, but can be changed at runtime or through configuration files.
The associated variable CVarSMRTMaxSlopeBiasLocal interacts directly with r.Shadow.Virtual.SMRT.MaxSlopeBiasLocal. They share the same value and purpose.
Developers must be aware that this variable has a significant impact on shadow quality and performance. As noted in the comments:
- Low values can produce artifacts if the shadow resolution is insufficient.
- High values can worsen light leaks near occluders and cause sparkly pixels in shadowed areas.
Best practices when using this variable include:
- Carefully balancing the value to avoid both artifacts and light leaks.
- Testing the impact of different values on various scenes and shadow resolutions.
- Considering the performance impact, as higher values might require more computational resources.
- Using it in conjunction with other shadow-related settings for optimal results.
Regarding the associated variable CVarSMRTMaxSlopeBiasLocal:
Its purpose is the same as r.Shadow.Virtual.SMRT.MaxSlopeBiasLocal - to control the maximum depth slope in virtual shadow maps.
It’s used in the same Renderer module and Virtual Shadow Maps subsystem.
The value is set through the CVar system and is accessed in the GetVirtualShadowMapSMRTSettings function.
Developers should treat CVarSMRTMaxSlopeBiasLocal as they would r.Shadow.Virtual.SMRT.MaxSlopeBiasLocal, following the same best practices and considerations mentioned above.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:133
Scope: file
Source code excerpt:
TAutoConsoleVariable<float> CVarSMRTMaxSlopeBiasLocal(
TEXT("r.Shadow.Virtual.SMRT.MaxSlopeBiasLocal"),
50.0f,
TEXT("Maximum depth slope. Low values produce artifacts if shadow resolution is insufficient. High values can worsen light leaks near occluders and sparkly pixels in shadowed areas."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarForcePerLightShadowMaskClear(
#Associated Variable and Callsites
This variable is associated with another variable named CVarSMRTMaxSlopeBiasLocal
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:132
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<float> CVarSMRTMaxSlopeBiasLocal(
TEXT("r.Shadow.Virtual.SMRT.MaxSlopeBiasLocal"),
50.0f,
TEXT("Maximum depth slope. Low values produce artifacts if shadow resolution is insufficient. High values can worsen light leaks near occluders and sparkly pixels in shadowed areas."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:206
Scope (from outer to inner):
file
function FVirtualShadowMapSMRTSettings GetVirtualShadowMapSMRTSettings
Source code excerpt:
Out.SMRTTexelDitherScale = CVarSMRTTexelDitherScaleLocal.GetValueOnRenderThread();
Out.SMRTExtrapolateSlope = CVarSMRTExtrapolateMaxSlopeLocal.GetValueOnRenderThread();
Out.SMRTMaxSlopeBias = CVarSMRTMaxSlopeBiasLocal.GetValueOnRenderThread();
}
return Out;
}
const TCHAR* ToString(EVirtualShadowMapProjectionInputType In)
{