r.DFShadowQuality
r.DFShadowQuality
#Overview
name: r.DFShadowQuality
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Defines the distance field shadow method which allows to adjust for quality or performance.\n 0:off, 1:low (20 steps, no SSS), 2:medium (32 steps, no SSS), 3:high (64 steps, SSS, default)
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DFShadowQuality is to control the quality of distance field shadows in Unreal Engine’s rendering system. This setting variable allows developers to adjust the trade-off between shadow quality and performance.
This setting variable is primarily used by the Renderer module of Unreal Engine, specifically in the distance field shadowing and mobile shading rendering subsystems.
The value of this variable is set through the console variable system. It is initialized with a default value of 3, which represents the highest quality setting. The variable can be changed at runtime using console commands or through project settings.
The r.DFShadowQuality variable directly interacts with the GDFShadowQuality variable. They share the same value, with GDFShadowQuality being the internal representation used in the C++ code.
Developers should be aware that this variable has four possible values: 0: Off (disables distance field shadows) 1: Low quality (20 steps, no subsurface scattering) 2: Medium quality (32 steps, no subsurface scattering) 3: High quality (64 steps, with subsurface scattering, default)
Best practices when using this variable include:
- Consider the target platform and performance requirements when choosing a quality level.
- Use lower quality settings for mobile platforms or when performance is a priority.
- Test the visual impact and performance implications of different quality levels in your specific use case.
- Be aware that changing this setting at runtime may have an immediate impact on rendering performance.
Regarding the associated variable GDFShadowQuality:
The purpose of GDFShadowQuality is to serve as the internal C++ representation of the r.DFShadowQuality console variable. It is used directly in the rendering code to determine the quality level of distance field shadows.
This variable is used within the Renderer module, specifically in the distance field shadowing system.
The value of GDFShadowQuality is set by the console variable system when r.DFShadowQuality is modified. It is initialized with a default value of 3.
GDFShadowQuality interacts directly with r.DFShadowQuality, as they share the same value. It is also used in the GetDFShadowQuality() function, which clamps its value between 0 and 3.
Developers should be aware that modifying GDFShadowQuality directly in C++ code is not recommended. Instead, they should use the r.DFShadowQuality console variable to ensure proper synchronization between the two variables.
Best practices for using GDFShadowQuality include:
- Avoid modifying it directly in C++ code.
- Use the GetDFShadowQuality() function when accessing its value in C++ code to ensure proper clamping.
- Be aware of its impact on rendering performance and adjust accordingly based on the target platform and project requirements.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldShadowing.cpp:42
Scope: file
Source code excerpt:
int32 GDFShadowQuality = 3;
FAutoConsoleVariableRef CVarDFShadowQuality(
TEXT("r.DFShadowQuality"),
GDFShadowQuality,
TEXT("Defines the distance field shadow method which allows to adjust for quality or performance.\n")
TEXT(" 0:off, 1:low (20 steps, no SSS), 2:medium (32 steps, no SSS), 3:high (64 steps, SSS, default)"),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileShadingRenderer.cpp:927
Scope (from outer to inner):
file
function void FMobileSceneRenderer::Render
Source code excerpt:
{
static auto CVarDistanceFieldShadowQuality = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DFShadowQuality"));
if (IsMobileDistanceFieldEnabled(ShaderPlatform)
&& ViewFamily.EngineShowFlags.Lighting
&& !Views[0].bIsReflectionCapture
&& !Views[0].bIsPlanarReflection
&& !ViewFamily.EngineShowFlags.VisualizeLightCulling
#Associated Variable and Callsites
This variable is associated with another variable named GDFShadowQuality
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldShadowing.cpp:40
Scope: file
Source code excerpt:
);
int32 GDFShadowQuality = 3;
FAutoConsoleVariableRef CVarDFShadowQuality(
TEXT("r.DFShadowQuality"),
GDFShadowQuality,
TEXT("Defines the distance field shadow method which allows to adjust for quality or performance.\n")
TEXT(" 0:off, 1:low (20 steps, no SSS), 2:medium (32 steps, no SSS), 3:high (64 steps, SSS, default)"),
ECVF_Scalability | ECVF_RenderThreadSafe
);
int32 GFullResolutionDFShadowing = 0;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldShadowing.cpp:693
Scope (from outer to inner):
file
function int32 GetDFShadowQuality
Source code excerpt:
int32 GetDFShadowQuality()
{
return FMath::Clamp(GDFShadowQuality, 0, 3);
}
int32 GetHFShadowQuality()
{
return FMath::Clamp(GHFShadowQuality, 0, 3);
}