r.Shadow.Virtual.SMRT.AdaptiveRayCount
r.Shadow.Virtual.SMRT.AdaptiveRayCount
#Overview
name: r.Shadow.Virtual.SMRT.AdaptiveRayCount
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Shoot fewer rays in fully shadowed and unshadowed regions. Currently only supported with OnePassProjection.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Virtual.SMRT.AdaptiveRayCount is to control the adaptive ray count feature in the Virtual Shadow Map system, specifically for the Sparse Mesh Ray Tracing (SMRT) technique. This setting allows for optimizing shadow rendering performance by reducing the number of rays cast in fully shadowed or unshadowed regions.
This setting variable is primarily used by the rendering system, specifically the Virtual Shadow Map subsystem within Unreal Engine 5. It is part of the shadow rendering optimization techniques.
The value of this variable is set through a console variable (CVar) system. It is defined in the VirtualShadowMapProjection.cpp file and can be modified at runtime or through configuration files.
The associated variable CVarSMRTAdaptiveRayCount directly interacts with r.Shadow.Virtual.SMRT.AdaptiveRayCount. They share the same value and purpose.
Developers must be aware that:
- This feature is currently only supported with OnePassProjection.
- The default value is 1, meaning the feature is enabled by default.
- This setting affects rendering performance and shadow quality, so it should be tuned carefully.
Best practices when using this variable include:
- Test thoroughly to ensure the desired balance between performance and shadow quality is achieved.
- Consider different scenarios (e.g., fully lit areas, areas with complex shadows) when adjusting this value.
- Use in conjunction with other shadow-related settings for optimal results.
Regarding the associated variable CVarSMRTAdaptiveRayCount:
- It is an internal representation of the r.Shadow.Virtual.SMRT.AdaptiveRayCount setting.
- It is used within the engine code to retrieve the current value of the setting, as seen in the GetVirtualShadowMapSMRTSettings function.
- Developers typically don’t need to interact with this variable directly, as it’s managed by the engine’s CVar system.
- When the value needs to be accessed in code, it’s retrieved using CVarSMRTAdaptiveRayCount.GetValueOnRenderThread(), ensuring thread-safe access to the current setting value.
#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:92
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarSMRTAdaptiveRayCount(
TEXT( "r.Shadow.Virtual.SMRT.AdaptiveRayCount" ),
1,
TEXT( "Shoot fewer rays in fully shadowed and unshadowed regions. Currently only supported with OnePassProjection. " ),
ECVF_Scalability | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarSMRTTexelDitherScaleLocal(
#Associated Variable and Callsites
This variable is associated with another variable named CVarSMRTAdaptiveRayCount
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:91
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarSMRTAdaptiveRayCount(
TEXT( "r.Shadow.Virtual.SMRT.AdaptiveRayCount" ),
1,
TEXT( "Shoot fewer rays in fully shadowed and unshadowed regions. Currently only supported with OnePassProjection. " ),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:187
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();
Out.SMRTCotMaxRayAngleFromLight = 0.0f; // unused in this path