r.Shadow.FarShadowDistanceOverride
r.Shadow.FarShadowDistanceOverride
#Overview
name: r.Shadow.FarShadowDistanceOverride
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Overriding far shadow distance for all directional lighst
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.FarShadowDistanceOverride is to override the far shadow distance for all directional lights in the scene. This setting variable is part of Unreal Engine 5’s rendering system, specifically targeting shadow rendering for directional lights.
The Unreal Engine subsystem that relies on this setting variable is the rendering system, particularly the shadow rendering component for directional lights. It’s used within the DirectionalLightComponent, which is part of the Engine module.
The value of this variable is set as a console variable (CVar) with an initial value of 0.0f. It can be modified at runtime through console commands or programmatically.
This variable interacts with other shadow-related variables, such as FarShadowDistance. When r.Shadow.FarShadowDistanceOverride is set to a value greater than 0, it takes precedence over the FarShadowDistance value.
Developers must be aware that:
- This variable affects all directional lights in the scene.
- It’s render thread safe and can be adjusted for scalability purposes.
- Setting this value to 0 or negative will cause the engine to use the default FarShadowDistance instead.
Best practices when using this variable include:
- Use it sparingly, as it overrides the far shadow distance for all directional lights, which might not always be desirable.
- Consider performance implications when increasing this value, as it may affect rendering performance.
- Use in conjunction with other shadow-related settings for fine-tuning shadow appearance and performance.
The associated variable CVarFarShadowDistanceOverride is the actual console variable that stores and provides access to the r.Shadow.FarShadowDistanceOverride value. It’s used internally by the engine to retrieve and apply the override value. The purpose and usage considerations for CVarFarShadowDistanceOverride are the same as those for r.Shadow.FarShadowDistanceOverride, as they represent the same setting in different contexts within the engine code.
#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:74
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarFarShadowDistanceOverride(
TEXT("r.Shadow.FarShadowDistanceOverride"),
0.0f,
TEXT("Overriding far shadow distance for all directional lighst"),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarRtdfFarTransitionScale(
TEXT("r.DFFarTransitionScale"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarFarShadowDistanceOverride
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/DirectionalLightComponent.cpp:73
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<float> CVarFarShadowDistanceOverride(
TEXT("r.Shadow.FarShadowDistanceOverride"),
0.0f,
TEXT("Overriding far shadow distance for all directional lighst"),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarRtdfFarTransitionScale(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/DirectionalLightComponent.cpp:517
Scope (from outer to inner):
file
class class FDirectionalLightSceneProxy : public FLightSceneProxy
function virtual FVector2D GetDirectionalLightDistanceFadeParameters
Source code excerpt:
FarDistance = GetDistanceFieldShadowDistance();
}
FarDistance = FMath::Max(FarDistance, CVarFarShadowDistanceOverride.GetValueOnAnyThread() > 0.0f ? CVarFarShadowDistanceOverride.GetValueOnAnyThread() : FarShadowDistance);
}
// 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));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/DirectionalLightComponent.cpp:789
Scope (from outer to inner):
file
class class FDirectionalLightSceneProxy : public FLightSceneProxy
function inline float GetSplitDistance
Source code excerpt:
uint32 ClampedFarShadowCascadeCount = FMath::Min((uint32)CVarMaxNumFarShadowCascades.GetValueOnAnyThread(), FarShadowCascadeCount);
return CascadeDistanceWithoutFar + ComputeAccumulatedScale(EffectiveCascadeDistributionExponent, SplitIndex - NumNearCascades, ClampedFarShadowCascadeCount) * ((CVarFarShadowDistanceOverride.GetValueOnAnyThread() > 0.0f ? CVarFarShadowDistanceOverride.GetValueOnAnyThread() : FarShadowDistance) - CascadeDistanceWithoutFar);
}
}
else
{
return ShadowNear + ComputeAccumulatedScale(EffectiveCascadeDistributionExponent, SplitIndex, NumNearCascades) * (CascadeDistanceWithoutFar - ShadowNear);
}