r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeLocal

r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeLocal

#Overview

name: r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeLocal

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.ExtrapolateMaxSlopeLocal is to control the maximum depth slope when extrapolating behind occluders for local lights in virtual shadow maps. This setting is part of the rendering system, specifically for shadow rendering optimization.

This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the Virtual Shadow Maps subsystem. It’s referenced in the VirtualShadowMapProjection.cpp file, which handles the projection of virtual shadow maps.

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

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

Developers must be aware that:

  1. Higher values allow for softer penumbra edges but can introduce light leaks behind second occluders.
  2. Setting this value to 0 will disable slope extrapolation, which slightly improves projection performance but at the cost of reduced penumbra quality.
  3. This setting affects the visual quality and performance of shadow rendering, particularly for local lights.

Best practices when using this variable include:

  1. Carefully balancing between shadow quality and performance. Higher values improve shadow softness but may introduce artifacts and impact performance.
  2. Testing different values in various lighting scenarios to find the optimal setting for your specific game or application.
  3. Consider exposing this setting as a scalability option, allowing users to adjust it based on their hardware capabilities.

Regarding the associated variable CVarSMRTExtrapolateMaxSlopeLocal:

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

Scope: file

Source code excerpt:


TAutoConsoleVariable<float> CVarSMRTExtrapolateMaxSlopeLocal(
	TEXT("r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeLocal"),
	0.05f,
	TEXT("Maximum depth slope when extrapolating behind occluders for local lights.\n")
	TEXT("Higher values allow softer penumbra edges but can introduce light leaks behind second occluders.\n")
	TEXT("Setting to 0 will disable slope extrapolation slightly improving projection performance, at the cost of reduced penumbra quality."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

TAutoConsoleVariable<float> CVarSMRTExtrapolateMaxSlopeLocal(
	TEXT("r.Shadow.Virtual.SMRT.ExtrapolateMaxSlopeLocal"),
	0.05f,
	TEXT("Maximum depth slope when extrapolating behind occluders for local lights.\n")
	TEXT("Higher values allow softer penumbra edges but can introduce light leaks behind second occluders.\n")
	TEXT("Setting to 0 will disable slope extrapolation slightly improving projection performance, at the cost of reduced penumbra quality."),
	ECVF_Scalability | ECVF_RenderThreadSafe

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

Scope (from outer to inner):

file
function     FVirtualShadowMapSMRTSettings GetVirtualShadowMapSMRTSettings

Source code excerpt:

		Out.SMRTCotMaxRayAngleFromLight = 1.0f / FMath::Tan(CVarSMRTMaxRayAngleFromLight.GetValueOnRenderThread());
		Out.SMRTTexelDitherScale = CVarSMRTTexelDitherScaleLocal.GetValueOnRenderThread();
		Out.SMRTExtrapolateSlope = CVarSMRTExtrapolateMaxSlopeLocal.GetValueOnRenderThread();
		Out.SMRTMaxSlopeBias = CVarSMRTMaxSlopeBiasLocal.GetValueOnRenderThread();
	}
	return Out;
}

const TCHAR* ToString(EVirtualShadowMapProjectionInputType In)