r.Shadow.FadeResolution
r.Shadow.FadeResolution
#Overview
name: r.Shadow.FadeResolution
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Resolution in texels below which shadows are faded out
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.FadeResolution is to control the resolution at which shadows start to fade out in Unreal Engine’s rendering system. This variable is used to define a threshold in texels below which shadows will begin to fade, improving performance by reducing the rendering cost of small or distant shadows.
This setting variable is primarily used in the Unreal Engine’s Renderer module, specifically in the shadow rendering subsystem. It’s referenced in files such as ShadowSetup.cpp and LightFunctionRendering.cpp, which are part of the core rendering pipeline.
The value of this variable is typically set through the console variable system. It’s defined with a default value of 64 texels in ShadowSetup.cpp. However, it can be modified at runtime or through configuration files.
The r.Shadow.FadeResolution variable interacts closely with other shadow-related variables, such as r.Shadow.MinResolution. Together, these variables control the behavior of shadow rendering and fading.
Developers should be aware that this variable directly affects the visual quality and performance of shadow rendering. Setting it too low might result in abrupt shadow pop-in, while setting it too high could negatively impact performance.
Best practices when using this variable include:
- Balancing it with other shadow-related settings for optimal visual quality and performance.
- Testing its effects across different hardware configurations.
- Considering dynamic adjustment based on the scene complexity or performance requirements.
Regarding the associated variable CVarShadowFadeResolution:
This is the C++ representation of the r.Shadow.FadeResolution console variable. It’s used internally by the engine to access and modify the shadow fade resolution setting.
CVarShadowFadeResolution is typically used in rendering code to retrieve the current value of the shadow fade resolution. It’s accessed using GetValueOnRenderThread() to ensure thread-safe operations in the rendering pipeline.
Developers working directly with the Unreal Engine C++ codebase should use this variable when they need to reference the shadow fade resolution in rendering-related calculations or decisions. It’s important to note that any changes to this variable will affect the engine’s shadow rendering behavior globally.
When using CVarShadowFadeResolution, developers should ensure they’re accessing it in the appropriate thread context (usually the render thread) and consider potential performance implications of frequent access or modification.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:235
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarShadowFadeResolution(
TEXT("r.Shadow.FadeResolution"),
64,
TEXT("Resolution in texels below which shadows are faded out"),
ECVF_Scalability | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarMinShadowResolution(
TEXT("r.Shadow.MinResolution"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SystemSettings.cpp:287
Scope (from outer to inner):
file
function void FSystemSettings::ApplyOverrides
Source code excerpt:
// Disable shadow fading out over distance
{
static auto CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Shadow.FadeResolution"));
CVar->Set(1, SetBy);
}
// Increase minimum preshadow resolution
{
static auto CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Shadow.MinPreShadowResolution"));
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightFunctionRendering.cpp:191
Scope (from outer to inner):
file
function float GetLightFunctionFadeFraction
Source code excerpt:
// Override the global settings with the light's settings if the light has them specified
static auto CVarMinShadowResolution = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Shadow.MinResolution"));
static auto CVarShadowFadeResolution = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Shadow.FadeResolution"));
const uint32 MinShadowResolution = FMath::Max<int32>(0, CVarMinShadowResolution->GetValueOnRenderThread());
const uint32 ShadowFadeResolution = FMath::Max<int32>(0, CVarShadowFadeResolution->GetValueOnRenderThread());
// Project the bounds onto the view
const FVector4 ScreenPosition = View.WorldToScreen(LightBounds.Center);
#Associated Variable and Callsites
This variable is associated with another variable named CVarShadowFadeResolution
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightFunctionRendering.cpp:191
Scope (from outer to inner):
file
function float GetLightFunctionFadeFraction
Source code excerpt:
// Override the global settings with the light's settings if the light has them specified
static auto CVarMinShadowResolution = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Shadow.MinResolution"));
static auto CVarShadowFadeResolution = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Shadow.FadeResolution"));
const uint32 MinShadowResolution = FMath::Max<int32>(0, CVarMinShadowResolution->GetValueOnRenderThread());
const uint32 ShadowFadeResolution = FMath::Max<int32>(0, CVarShadowFadeResolution->GetValueOnRenderThread());
// Project the bounds onto the view
const FVector4 ScreenPosition = View.WorldToScreen(LightBounds.Center);
int32 SizeX = View.ViewRect.Width();
int32 SizeY = View.ViewRect.Height();
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:234
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarShadowFadeResolution(
TEXT("r.Shadow.FadeResolution"),
64,
TEXT("Resolution in texels below which shadows are faded out"),
ECVF_Scalability | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarMinShadowResolution(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:3316
Scope (from outer to inner):
file
function void FSceneRenderer::CreatePerObjectProjectedShadow
Source code excerpt:
const uint32 MaxShadowResolutionY = FMath::Min<int32>(MaxShadowResolutionSetting, ShadowBufferResolution.Y) - SHADOW_BORDER * 2;
const uint32 MinShadowResolution = FMath::Max<int32>(0, CVarMinShadowResolution.GetValueOnRenderThread());
const uint32 ShadowFadeResolution = FMath::Max<int32>(0, CVarShadowFadeResolution.GetValueOnRenderThread());
const uint32 MinPreShadowResolution = FMath::Max<int32>(0, CVarMinPreShadowResolution.GetValueOnRenderThread());
const uint32 PreShadowFadeResolution = FMath::Max<int32>(0, CVarPreShadowFadeResolution.GetValueOnRenderThread());
// Compute the maximum resolution required for the shadow by any view. Also keep track of the unclamped resolution for fading.
uint32 MaxDesiredResolution = 0;
float MaxScreenPercent = 0;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:4064
Scope (from outer to inner):
file
function void FSceneRenderer::CreateWholeSceneProjectedShadow
Source code excerpt:
const uint32 MaxShadowResolution = FMath::Min(MaxShadowResolutionSetting, ShadowBufferResolution.X) - EffectiveDoubleShadowBorder;
const uint32 MaxShadowResolutionY = FMath::Min(MaxShadowResolutionSetting, ShadowBufferResolution.Y) - EffectiveDoubleShadowBorder;
const uint32 ShadowFadeResolution = FMath::Max<int32>(0, CVarShadowFadeResolution.GetValueOnRenderThread());
// Compute the maximum resolution required for the shadow by any view. Also keep track of the unclamped resolution for fading.
float MaxDesiredResolution = 0.0f;
float MaxScreenRadius = 0.0f;
TArray<float, TInlineAllocator<2> > FadeAlphas;