r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeDirectional
r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeDirectional
#Overview
name: r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeDirectional
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Maximum depth slope when extrapolating behind occluders for directional lights.\nHigher values allow softer penumbra edges but can introduce light leaks behind second occluders.\nSetting to 0 will disable slope extrapolation slightly improving projection performance, at the cost of reduced penumbra quality.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeDirectional is to control the maximum depth slope when extrapolating behind occluders for directional lights in the Virtual Shadow Map system of Unreal Engine 5.
This setting variable is primarily used in the rendering system, specifically for the Virtual Shadow Map (VSM) feature. It is part of the Sparse Matrix Row Technique (SMRT) used for shadow mapping.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the Virtual Shadow Map component. This can be seen from the file path where the variable is defined: Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp
.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 5.0f, but can be changed at runtime through console commands or configuration files.
This variable interacts closely with other SMRT-related variables for Virtual Shadow Maps, such as CVarSMRTTexelDitherScaleDirectional, as seen in the GetVirtualShadowMapSMRTSettings function.
Developers must be aware that this variable affects the quality and performance trade-off in shadow rendering. Higher values allow for softer penumbra edges but can introduce light leaks behind secondary occluders. Setting it to 0 disables slope extrapolation, which slightly improves projection performance at the cost of reduced penumbra quality.
Best practices when using this variable include:
- Adjusting it based on the specific needs of the scene, considering both visual quality and performance.
- Testing different values to find the optimal balance between soft penumbras and avoiding light leaks.
- Consider disabling it (setting to 0) if performance is critical and the loss in penumbra quality is acceptable.
Regarding the associated variable CVarSMRTExtrapolateMaxSlopeDirectional:
This is the actual console variable that stores and manages the value of r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeDirectional. It’s defined using the TAutoConsoleVariable template, which is part of Unreal Engine’s configuration system.
The purpose of this variable is the same as r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeDirectional, as they represent the same setting.
It’s used in the Renderer module, specifically in the Virtual Shadow Map system.
The value is set when the variable is initialized (default 5.0f) and can be changed at runtime through console commands.
This variable interacts directly with the rendering code, as seen in the GetVirtualShadowMapSMRTSettings function where its value is retrieved using GetValueOnRenderThread().
Developers should be aware that this is the actual variable used in the code, and any changes to r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeDirectional will be reflected in this variable.
Best practices include using the appropriate console commands or configuration settings to modify this value, rather than trying to change it directly in code, unless absolutely necessary.
#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:124
Scope: file
Source code excerpt:
TAutoConsoleVariable<float> CVarSMRTExtrapolateMaxSlopeDirectional(
TEXT("r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeDirectional"),
5.0f,
TEXT("Maximum depth slope when extrapolating behind occluders for directional lights.\n")
TEXT("Higher values allow softer penumbra edges but can introduce light leaks behind second occluders.\n")
TEXT("Setting to 0 will disable slope extrapolation slightly improving projection performance, at the cost of reduced penumbra quality."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Associated Variable and Callsites
This variable is associated with another variable named CVarSMRTExtrapolateMaxSlopeDirectional
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:123
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<float> CVarSMRTExtrapolateMaxSlopeDirectional(
TEXT("r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeDirectional"),
5.0f,
TEXT("Maximum depth slope when extrapolating behind occluders for directional lights.\n")
TEXT("Higher values allow softer penumbra edges but can introduce light leaks behind second occluders.\n")
TEXT("Setting to 0 will disable slope extrapolation slightly improving projection performance, at the cost of reduced penumbra quality."),
ECVF_Scalability | ECVF_RenderThreadSafe
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:195
Scope (from outer to inner):
file
function FVirtualShadowMapSMRTSettings GetVirtualShadowMapSMRTSettings
Source code excerpt:
Out.SMRTCotMaxRayAngleFromLight = 0.0f; // unused in this path
Out.SMRTTexelDitherScale = CVarSMRTTexelDitherScaleDirectional.GetValueOnRenderThread();
Out.SMRTExtrapolateSlope = CVarSMRTExtrapolateMaxSlopeDirectional.GetValueOnRenderThread();
Out.SMRTMaxSlopeBias = 0.0f; // unused in this path
}
else
{
Out.SMRTRayCount = CVarSMRTRayCountLocal.GetValueOnRenderThread();
Out.SMRTSamplesPerRay = CVarSMRTSamplesPerRayLocal.GetValueOnRenderThread();