r.Shadow.TransitionScale
r.Shadow.TransitionScale
#Overview
name: r.Shadow.TransitionScale
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
This controls the \'fade in\' region between a caster and where its shadow shows up. Larger values make a smaller region which will have more self shadowing artifacts
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.TransitionScale is to control the ‘fade in’ region between a shadow caster and where its shadow appears in the scene. This setting variable is primarily used in the rendering system, specifically for shadow rendering.
This setting variable is utilized by the Renderer module of Unreal Engine 5, as evidenced by its presence in the ShadowRendering.cpp file.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 60.0f, but can be modified at runtime through console commands or programmatically.
The associated variable CVarShadowTransitionScale directly interacts with r.Shadow.TransitionScale. They share the same value and purpose.
Developers must be aware that larger values for this variable result in a smaller transition region, which can lead to more self-shadowing artifacts. Conversely, smaller values will create a larger transition region, potentially reducing artifacts but possibly affecting performance.
Best practices when using this variable include:
- Carefully adjusting the value to balance between visual quality and performance.
- Testing different values in various lighting scenarios to ensure optimal results across different game environments.
- Considering the interaction with other shadow-related settings, such as shadow bias.
Regarding the associated variable CVarShadowTransitionScale:
The purpose of CVarShadowTransitionScale is the same as r.Shadow.TransitionScale - it controls the shadow transition scale in the rendering system.
This variable is used directly in the ComputeTransitionSize function within the FProjectedShadowInfo class. It’s accessed using the GetValueOnRenderThread() method, indicating that it’s designed for use in render thread operations.
The value of CVarShadowTransitionScale is set when the console variable is initialized, but can be modified at runtime.
CVarShadowTransitionScale interacts with other variables in the shadow rendering system, such as CVarSpotLightShadowTransitionScale for spot lights.
Developers should be aware that this variable is used in calculations that directly affect shadow rendering, particularly in transition size computations. Changes to this value will impact the appearance of shadows in the scene.
Best practices for using CVarShadowTransitionScale include:
- Coordinating changes with r.Shadow.TransitionScale, as they share the same value.
- Considering the impact on both directional and spot light shadows when modifying this value.
- Balancing the transition size with other shadow parameters for optimal visual results.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:63
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarShadowTransitionScale(
TEXT("r.Shadow.TransitionScale"),
60.0f,
TEXT("This controls the 'fade in' region between a caster and where its shadow shows up. Larger values make a smaller region which will have more self shadowing artifacts"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarCSMShadowReceiverBias(
TEXT("r.Shadow.CSMReceiverBias"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarShadowTransitionScale
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:62
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarShadowTransitionScale(
TEXT("r.Shadow.TransitionScale"),
60.0f,
TEXT("This controls the 'fade in' region between a caster and where its shadow shows up. Larger values make a smaller region which will have more self shadowing artifacts"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarCSMShadowReceiverBias(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:1917
Scope (from outer to inner):
file
function float FProjectedShadowInfo::ComputeTransitionSize
Source code excerpt:
{
// todo: optimize
TransitionSize = bDirectionalLight ? (1.0f / CVarShadowTransitionScale.GetValueOnRenderThread()) : (1.0f / CVarSpotLightShadowTransitionScale.GetValueOnRenderThread());
// * 2.0f to be compatible with the system we had before ShadowBias
TransitionSize *= 2.0f * LightSceneInfo->Proxy->GetUserShadowBias();
}
else if (IsWholeSceneDirectionalShadow())
{
check(CascadeSettings.ShadowSplitIndex >= 0);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:1944
Scope (from outer to inner):
file
function float FProjectedShadowInfo::ComputeTransitionSize
Source code excerpt:
{
// todo: optimize
TransitionSize = bDirectionalLight ? (1.0f / CVarShadowTransitionScale.GetValueOnRenderThread()) : (1.0f / CVarSpotLightShadowTransitionScale.GetValueOnRenderThread());
// * 2.0f to be compatible with the system we had before ShadowBias
TransitionSize *= 2.0f * LightSceneInfo->Proxy->GetUserShadowBias();
}
// Make sure that shadow soft transition size is greater than zero so 1/TransitionSize shader parameter won't be INF.
const float MinTransitionSize = 0.00001f;