r.Shadow.Virtual.ScreenRayLength
r.Shadow.Virtual.ScreenRayLength
#Overview
name: r.Shadow.Virtual.ScreenRayLength
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Length of the screen space shadow trace away from receiver surface (smart shadow bias) before the VSM / SMRT lookup.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Virtual.ScreenRayLength is to control the length of the screen space shadow trace away from the receiver surface before performing a Virtual Shadow Map (VSM) or Screen-space Multi-Resolution Tracing (SMRT) lookup. This setting is part of the shadow rendering system in Unreal Engine 5.
This setting variable is primarily used in the Renderer module, specifically within the Virtual Shadow Maps subsystem. It’s referenced in the VirtualShadowMapProjection.cpp file, which is responsible for handling virtual shadow map projections.
The value of this variable is set through a console variable (CVar) system, with a default value of 0.015f. It can be modified at runtime using console commands or through project settings.
The associated variable CVarScreenRayLength directly interacts with r.Shadow.Virtual.ScreenRayLength. They share the same value and purpose.
Developers should be aware that this variable affects the smart shadow bias mechanism. Adjusting this value can impact shadow quality and performance. A longer ray length may reduce shadow artifacts but could potentially increase the computational cost.
Best practices when using this variable include:
- Fine-tuning the value based on the specific needs of the scene or project.
- Testing different values to find the optimal balance between shadow quality and performance.
- Considering the impact on different hardware configurations, as this setting can affect scalability.
Regarding the associated variable CVarScreenRayLength:
The purpose of CVarScreenRayLength is the same as r.Shadow.Virtual.ScreenRayLength. It’s used to store and access the screen ray length value within the C++ code.
This variable is part of the Renderer module and is specifically used in the Virtual Shadow Maps subsystem.
The value of CVarScreenRayLength is set using the TAutoConsoleVariable template, which allows it to be modified through the console or project settings.
CVarScreenRayLength directly interacts with r.Shadow.Virtual.ScreenRayLength, as they represent the same setting.
Developers should be aware that CVarScreenRayLength is used to retrieve the current value of the setting in the render thread, as seen in the GetVirtualShadowMapSMRTSettings function.
Best practices for using CVarScreenRayLength include:
- Accessing its value using the GetValueOnRenderThread() method when needed in render thread operations.
- Avoiding direct modification of the variable in code; instead, use the console variable system to change its value.
- Considering the performance implications when frequently accessing this value in performance-critical sections of code.
#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:31
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarScreenRayLength(
TEXT( "r.Shadow.Virtual.ScreenRayLength" ),
0.015f,
TEXT( "Length of the screen space shadow trace away from receiver surface (smart shadow bias) before the VSM / SMRT lookup." ),
ECVF_Scalability | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarNormalBias(
#Associated Variable and Callsites
This variable is associated with another variable named CVarScreenRayLength
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:30
Scope: file
Source code excerpt:
#define MAX_TEST_PERMUTATION 0
static TAutoConsoleVariable<float> CVarScreenRayLength(
TEXT( "r.Shadow.Virtual.ScreenRayLength" ),
0.015f,
TEXT( "Length of the screen space shadow trace away from receiver surface (smart shadow bias) before the VSM / SMRT lookup." ),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:186
Scope (from outer to inner):
file
function FVirtualShadowMapSMRTSettings GetVirtualShadowMapSMRTSettings
Source code excerpt:
{
FVirtualShadowMapSMRTSettings Out;
Out.ScreenRayLength = CVarScreenRayLength.GetValueOnRenderThread();
Out.SMRTAdaptiveRayCount = CVarSMRTAdaptiveRayCount.GetValueOnRenderThread();
if (bDirectionalLight)
{
Out.SMRTRayCount = CVarSMRTRayCountDirectional.GetValueOnRenderThread();
Out.SMRTSamplesPerRay = CVarSMRTSamplesPerRayDirectional.GetValueOnRenderThread();
Out.SMRTRayLengthScale = CVarSMRTRayLengthScaleDirectional.GetValueOnRenderThread();