r.Shadow.Virtual.SMRT.RayLengthScaleDirectional

r.Shadow.Virtual.SMRT.RayLengthScaleDirectional

#Overview

name: r.Shadow.Virtual.SMRT.RayLengthScaleDirectional

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Shadow.Virtual.SMRT.RayLengthScaleDirectional is to control the length of rays shot for directional lights in the virtual shadow map system, specifically for the Stable Mesh Ray Tracing (SMRT) technique. This setting variable is part of the rendering system, particularly the shadow rendering subsystem.

This setting variable is used in the Renderer module of Unreal Engine 5, specifically in the Virtual Shadow Maps feature. It’s primarily referenced in the VirtualShadowMapProjection.cpp file, which is responsible for handling shadow map projections for virtual shadow maps.

The value of this variable is set through a console variable (CVar) system, which allows for runtime configuration. It’s initialized with a default value of 1.5f, but can be changed during runtime or through configuration files.

The associated variable CVarSMRTRayLengthScaleDirectional directly interacts with r.Shadow.Virtual.SMRT.RayLengthScaleDirectional. They share the same value and purpose.

Developers must be aware that this variable affects the trade-off between shadow quality and performance. Shorter rays limit the screen space size of shadow penumbra, while longer rays require more samples to avoid shadows disconnecting from contact points. Adjusting this value can have a significant impact on both shadow appearance and rendering performance.

Best practices when using this variable include:

  1. Carefully balancing between shadow quality and performance based on the specific needs of the project.
  2. Testing different values to find the optimal setting for the specific scene and lighting conditions.
  3. Considering the relationship between this variable and other shadow-related settings, such as ray count and samples per ray.

Regarding the associated variable CVarSMRTRayLengthScaleDirectional:

The purpose of CVarSMRTRayLengthScaleDirectional is to provide a configurable interface for the r.Shadow.Virtual.SMRT.RayLengthScaleDirectional setting. It’s part of the console variable system in Unreal Engine, allowing for runtime configuration of the ray length scale for directional lights in virtual shadow maps.

This variable is used in the same Renderer module and Virtual Shadow Maps feature as r.Shadow.Virtual.SMRT.RayLengthScaleDirectional. It’s defined and used in the VirtualShadowMapProjection.cpp file.

The value of CVarSMRTRayLengthScaleDirectional is set when the engine initializes the console variable system, but can be changed at runtime through console commands or configuration files.

CVarSMRTRayLengthScaleDirectional directly interacts with r.Shadow.Virtual.SMRT.RayLengthScaleDirectional, as they represent the same setting.

Developers should be aware that changes to CVarSMRTRayLengthScaleDirectional will directly affect the behavior of the virtual shadow map system for directional lights. It’s used in the GetVirtualShadowMapSMRTSettings function to configure the SMRT settings for shadow calculation.

Best practices for using CVarSMRTRayLengthScaleDirectional include:

  1. Using it for fine-tuning shadow appearance and performance during development and testing.
  2. Documenting any non-default values used in the project for easier maintenance and optimization.
  3. Consider exposing this setting in a user-friendly way if runtime configuration is needed in the final product.

#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:83

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarSMRTRayLengthScaleDirectional(
	TEXT( "r.Shadow.Virtual.SMRT.RayLengthScaleDirectional" ),
	1.5f,
	TEXT( "Length of ray to shoot for directional lights, scaled by distance to camera." )
	TEXT( "Shorter rays limit the screen space size of shadow penumbra. " )
	TEXT( "Longer rays require more samples to avoid shadows disconnecting from contact points. " ),
	ECVF_RenderThreadSafe
);

#Associated Variable and Callsites

This variable is associated with another variable named CVarSMRTRayLengthScaleDirectional. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:82

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<float> CVarSMRTRayLengthScaleDirectional(
	TEXT( "r.Shadow.Virtual.SMRT.RayLengthScaleDirectional" ),
	1.5f,
	TEXT( "Length of ray to shoot for directional lights, scaled by distance to camera." )
	TEXT( "Shorter rays limit the screen space size of shadow penumbra. " )
	TEXT( "Longer rays require more samples to avoid shadows disconnecting from contact points. " ),
	ECVF_RenderThreadSafe

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:192

Scope (from outer to inner):

file
function     FVirtualShadowMapSMRTSettings GetVirtualShadowMapSMRTSettings

Source code excerpt:

		Out.SMRTRayCount = CVarSMRTRayCountDirectional.GetValueOnRenderThread();
		Out.SMRTSamplesPerRay = CVarSMRTSamplesPerRayDirectional.GetValueOnRenderThread();
		Out.SMRTRayLengthScale = CVarSMRTRayLengthScaleDirectional.GetValueOnRenderThread();
		Out.SMRTCotMaxRayAngleFromLight = 0.0f;	// unused in this path
		Out.SMRTTexelDitherScale = CVarSMRTTexelDitherScaleDirectional.GetValueOnRenderThread();
		Out.SMRTExtrapolateSlope = CVarSMRTExtrapolateMaxSlopeDirectional.GetValueOnRenderThread();
		Out.SMRTMaxSlopeBias = 0.0f; // unused in this path
	}
	else