r.Shadow.Virtual.SMRT.MaxRayAngleFromLight
r.Shadow.Virtual.SMRT.MaxRayAngleFromLight
#Overview
name: r.Shadow.Virtual.SMRT.MaxRayAngleFromLight
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Max angle (in radians) a ray is allowed to span from the light\'s perspective for local lights.Smaller angles limit the screen space size of shadow penumbra. Larger angles lead to more noise.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Virtual.SMRT.MaxRayAngleFromLight is to control the maximum angle (in radians) that a ray is allowed to span from the light’s perspective for local lights in the Virtual Shadow Map system. This setting is part of the rendering system, specifically for shadow rendering.
This setting variable is used in the Renderer module of Unreal Engine 5, particularly in the Virtual Shadow Maps subsystem. It’s implemented in the VirtualShadowMapProjection.cpp file, which suggests it’s integral to the shadow projection calculations for virtual shadow maps.
The value of this variable is set as a console variable with a default value of 0.03 radians (approximately 1.72 degrees). It can be adjusted at runtime through the console or configuration files.
The associated variable CVarSMRTMaxRayAngleFromLight directly interacts with r.Shadow.Virtual.SMRT.MaxRayAngleFromLight. They share the same value and purpose.
Developers must be aware that this variable affects the trade-off between shadow penumbra size and noise in the shadows. Smaller angles limit the screen space size of shadow penumbra, while larger angles lead to more noise in the shadows.
Best practices when using this variable include:
- Adjusting it carefully to balance shadow quality and performance.
- Testing different values to find the optimal setting for your specific scene and lighting setup.
- Being mindful of its impact on both visual quality and rendering performance.
Regarding the associated variable CVarSMRTMaxRayAngleFromLight:
The purpose of CVarSMRTMaxRayAngleFromLight is the same as r.Shadow.Virtual.SMRT.MaxRayAngleFromLight. It’s the internal representation of the console variable in the C++ code.
This variable is used in the Renderer module, specifically in the Virtual Shadow Maps system. It’s defined and used in the VirtualShadowMapProjection.cpp file.
The value of CVarSMRTMaxRayAngleFromLight is set when the console variable r.Shadow.Virtual.SMRT.MaxRayAngleFromLight is initialized or changed.
CVarSMRTMaxRayAngleFromLight interacts directly with the FVirtualShadowMapSMRTSettings struct, where its value is used to calculate the SMRTCotMaxRayAngleFromLight field.
Developers should be aware that this variable is used in the render thread, as indicated by the ECVF_RenderThreadSafe flag and the use of GetValueOnRenderThread() method.
Best practices for using CVarSMRTMaxRayAngleFromLight include:
- Accessing its value using the GetValueOnRenderThread() method when in the render thread.
- Considering its impact on shadow quality and performance when adjusting related shadow settings.
- Understanding its relationship with other SMRT (likely “Shadow Map Ray Tracing”) settings in the Virtual Shadow Map system.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:60
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarSMRTMaxRayAngleFromLight(
TEXT( "r.Shadow.Virtual.SMRT.MaxRayAngleFromLight" ),
0.03f,
TEXT( "Max angle (in radians) a ray is allowed to span from the light's perspective for local lights." )
TEXT( "Smaller angles limit the screen space size of shadow penumbra. " )
TEXT( "Larger angles lead to more noise. " ),
ECVF_RenderThreadSafe
);
#Associated Variable and Callsites
This variable is associated with another variable named CVarSMRTMaxRayAngleFromLight
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:59
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<float> CVarSMRTMaxRayAngleFromLight(
TEXT( "r.Shadow.Virtual.SMRT.MaxRayAngleFromLight" ),
0.03f,
TEXT( "Max angle (in radians) a ray is allowed to span from the light's perspective for local lights." )
TEXT( "Smaller angles limit the screen space size of shadow penumbra. " )
TEXT( "Larger angles lead to more noise. " ),
ECVF_RenderThreadSafe
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:203
Scope (from outer to inner):
file
function FVirtualShadowMapSMRTSettings GetVirtualShadowMapSMRTSettings
Source code excerpt:
Out.SMRTSamplesPerRay = CVarSMRTSamplesPerRayLocal.GetValueOnRenderThread();
Out.SMRTRayLengthScale = 0.0f; // unused in this path
Out.SMRTCotMaxRayAngleFromLight = 1.0f / FMath::Tan(CVarSMRTMaxRayAngleFromLight.GetValueOnRenderThread());
Out.SMRTTexelDitherScale = CVarSMRTTexelDitherScaleLocal.GetValueOnRenderThread();
Out.SMRTExtrapolateSlope = CVarSMRTExtrapolateMaxSlopeLocal.GetValueOnRenderThread();
Out.SMRTMaxSlopeBias = CVarSMRTMaxSlopeBiasLocal.GetValueOnRenderThread();
}
return Out;
}