r.Shadow.FilterMethod
r.Shadow.FilterMethod
#Overview
name: r.Shadow.FilterMethod
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Chooses the shadow filtering method.\n 0: Uniform PCF (default)\n 1: PCSS (experimental)\n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.FilterMethod is to control the shadow filtering method used in the rendering system of Unreal Engine 5. This setting variable allows developers to choose between different shadow filtering techniques, which can affect the visual quality and performance of shadow rendering in the game.
This setting variable is primarily used by the Renderer module of Unreal Engine 5, specifically within the shadow rendering subsystem. Based on the callsites, we can see that it’s referenced in the ShadowRendering.cpp file, which is part of the core rendering functionality.
The value of this variable is set through a console variable (CVar) system. It’s defined using TAutoConsoleVariable, which allows it to be changed at runtime through console commands or configuration files. The default value is set to 0, which corresponds to Uniform PCF (Percentage Closer Filtering).
The associated variable CVarFilterMethod directly interacts with r.Shadow.FilterMethod. They share the same value and are used interchangeably in the code.
Developers must be aware that:
- This variable affects the visual quality and potentially the performance of shadow rendering.
- It currently supports two modes: 0 for Uniform PCF (default) and 1 for PCSS (Percentage-Closer Soft Shadows), which is marked as experimental.
- Changes to this variable are render thread safe, meaning they can be applied without causing threading issues.
Best practices when using this variable include:
- Carefully consider the performance implications when switching to PCSS, as it may be more computationally expensive.
- Test thoroughly when using the experimental PCSS method to ensure it meets quality and performance requirements.
- Use this variable in conjunction with other shadow-related settings for optimal results.
- Consider exposing this setting to end-users if you want to give them control over shadow quality vs. performance.
Regarding the associated variable CVarFilterMethod: The purpose of CVarFilterMethod is to provide a programmatic way to access and modify the r.Shadow.FilterMethod setting within the C++ code. It’s used in conditional statements to determine which shadow projection shaders to bind based on the selected filtering method. This allows the engine to switch between different shadow rendering techniques at runtime, providing flexibility in shadow quality and performance optimization.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:175
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarFilterMethod(
TEXT("r.Shadow.FilterMethod"),
0,
TEXT("Chooses the shadow filtering method.\n")
TEXT(" 0: Uniform PCF (default)\n")
TEXT(" 1: PCSS (experimental)\n"),
ECVF_RenderThreadSafe);
#Associated Variable and Callsites
This variable is associated with another variable named CVarFilterMethod
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:174
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarFilterMethod(
TEXT("r.Shadow.FilterMethod"),
0,
TEXT("Chooses the shadow filtering method.\n")
TEXT(" 0: Uniform PCF (default)\n")
TEXT(" 1: PCSS (experimental)\n"),
ECVF_RenderThreadSafe);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:538
Scope (from outer to inner):
file
function static void BindShadowProjectionShaders
Source code excerpt:
else if (ShadowInfo->IsWholeSceneDirectionalShadow())
{
if (CVarFilterMethod.GetValueOnRenderThread() == 1)
{
if (ShadowInfo->CascadeSettings.FadePlaneLength > 0)
BindShaderShaders<FShadowProjectionNoTransformVS, TDirectionalPercentageCloserShadowProjectionPS<5, true> >(RHICmdList, GraphicsPSOInit, ViewIndex, View, ShadowInfo, StencilRef);
else
BindShaderShaders<FShadowProjectionNoTransformVS, TDirectionalPercentageCloserShadowProjectionPS<5, false> >(RHICmdList, GraphicsPSOInit, ViewIndex, View, ShadowInfo, StencilRef);
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:634
Scope (from outer to inner):
file
function static void BindShadowProjectionShaders
Source code excerpt:
else
{
if (CVarFilterMethod.GetValueOnRenderThread() == 1 && ShadowInfo->GetLightSceneInfo().Proxy->GetLightType() == LightType_Spot)
{
BindShaderShaders<FShadowVolumeBoundProjectionVS, TSpotPercentageCloserShadowProjectionPS<5, false> >(RHICmdList, GraphicsPSOInit, ViewIndex, View, ShadowInfo, StencilRef);
}
else
{
switch (Quality)