r.Shadow.CSMShadowDistanceFadeoutMultiplier
r.Shadow.CSMShadowDistanceFadeoutMultiplier
#Overview
name: r.Shadow.CSMShadowDistanceFadeoutMultiplier
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Multiplier for the CSM distance fade
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.CSMShadowDistanceFadeoutMultiplier is to control the fade-out distance of Cascaded Shadow Maps (CSM) in Unreal Engine’s rendering system. This variable acts as a multiplier for the CSM distance fade, allowing developers to fine-tune the transition between dynamic and static shadows.
This setting variable is primarily used by the rendering system, specifically in the shadow rendering pipeline. Based on the callsites, it’s evident that the Directional Light component in Unreal Engine relies on this variable.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1.0f and can be modified at runtime or through configuration files.
The associated variable CVarCSMShadowDistanceFadeoutMultiplier directly interacts with r.Shadow.CSMShadowDistanceFadeoutMultiplier. They share the same value and purpose.
Developers must be aware that this variable affects the visual quality and performance of shadow rendering, particularly for directional lights. Adjusting this value will impact the distance at which shadows transition from dynamic to static, which can affect both the visual fidelity and rendering performance.
Best practices when using this variable include:
- Carefully balancing visual quality and performance requirements.
- Testing different values in various lighting scenarios to find the optimal setting for your specific game or application.
- Considering scalability options, as the variable is marked with ECVF_Scalability, indicating it can be adjusted based on different hardware capabilities.
Regarding the associated variable CVarCSMShadowDistanceFadeoutMultiplier:
The purpose of CVarCSMShadowDistanceFadeoutMultiplier is identical to r.Shadow.CSMShadowDistanceFadeoutMultiplier. It’s the C++ representation of the console variable used within the engine’s code.
This variable is used in the DirectionalLightComponent.cpp file, specifically within the FDirectionalLightSceneProxy class. It’s utilized in the GetDirectionalLightDistanceFadeParameters function to calculate the near distance for the dynamic to static shadow fade.
The value of this variable is set through the CVar system and can be accessed using the GetValueOnAnyThread() method.
CVarCSMShadowDistanceFadeoutMultiplier directly interacts with the shadow rendering system, affecting how directional light shadows are faded out over distance.
Developers should be aware that this variable is accessed on potentially any thread (GetValueOnAnyThread()), which means it should be treated as a volatile value that can change at any time.
Best practices for using CVarCSMShadowDistanceFadeoutMultiplier include:
- Ensuring thread-safe access when reading or modifying the value.
- Considering the performance implications of frequently accessing this value, especially in performance-critical code paths.
- Using this variable in conjunction with other shadow-related settings to achieve the desired visual and performance balance.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:906, section: [Android_Vulkan_SM5 DeviceProfile]
- INI Section:
Android_Vulkan_SM5 DeviceProfile
- Raw value:
2.5
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/DirectionalLightComponent.cpp:41
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarCSMShadowDistanceFadeoutMultiplier(
TEXT("r.Shadow.CSMShadowDistanceFadeoutMultiplier"),
1.0f,
TEXT("Multiplier for the CSM distance fade"),
ECVF_RenderThreadSafe | ECVF_Scalability );
static TAutoConsoleVariable<float> CVarPerObjectCastDistanceRadiusScale(
TEXT("r.Shadow.PerObjectCastDistanceRadiusScale"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarCSMShadowDistanceFadeoutMultiplier
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/DirectionalLightComponent.cpp:40
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarCSMShadowDistanceFadeoutMultiplier(
TEXT("r.Shadow.CSMShadowDistanceFadeoutMultiplier"),
1.0f,
TEXT("Multiplier for the CSM distance fade"),
ECVF_RenderThreadSafe | ECVF_Scalability );
static TAutoConsoleVariable<float> CVarPerObjectCastDistanceRadiusScale(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/DirectionalLightComponent.cpp:522
Scope (from outer to inner):
file
class class FDirectionalLightSceneProxy : public FLightSceneProxy
function virtual FVector2D GetDirectionalLightDistanceFadeParameters
Source code excerpt:
// The far distance for the dynamic to static fade is the range of the directional light.
// The near distance is placed at a depth of 90% of the light's range.
const float NearDistance = FarDistance - FarDistance * ( ShadowDistanceFadeoutFraction * CVarCSMShadowDistanceFadeoutMultiplier.GetValueOnAnyThread() );
return FVector2D(NearDistance, 1.0f / FMath::Max<float>(FarDistance - NearDistance, UE_KINDA_SMALL_NUMBER));
}
virtual int32 GetDirectionalLightForwardShadingPriority() const override
{
return ForwardShadingPriority;