r.Shadow.Virtual.SMRT.TexelDitherScaleLocal

r.Shadow.Virtual.SMRT.TexelDitherScaleLocal

#Overview

name: r.Shadow.Virtual.SMRT.TexelDitherScaleLocal

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.TexelDitherScaleLocal is to apply a dither effect to shadow map ray casts for local lights in the virtual shadow mapping system. This setting is part of the rendering system, specifically related to shadow rendering.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, 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 as a console variable with a default value of 2.0f. It can be modified at runtime through the console or configuration files.

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

Developers must be aware that this variable affects the quality and performance of shadow rendering for local lights. Setting the value too high can cause shadow light leaks near occluders, which may result in visual artifacts.

Best practices when using this variable include:

  1. Carefully adjusting the value to balance between hiding aliasing and avoiding light leaks.
  2. Testing the effects of different values in various lighting scenarios to find the optimal setting for your specific use case.
  3. Considering the performance impact of higher values, as increased dithering may affect rendering performance.

Regarding the associated variable CVarSMRTTexelDitherScaleLocal:

The purpose of CVarSMRTTexelDitherScaleLocal is identical to r.Shadow.Virtual.SMRT.TexelDitherScaleLocal. It’s an internal representation of the console variable used within the engine’s code.

This variable is used in the GetVirtualShadowMapSMRTSettings function to retrieve the current value of the dither scale for local lights. It’s part of the Virtual Shadow Map system in the Renderer module.

The value of CVarSMRTTexelDitherScaleLocal is set by the console variable system and can be accessed using the GetValueOnRenderThread() method.

Developers should be aware that this variable is used directly in shadow rendering calculations and any changes to it will immediately affect the shadow quality for local lights.

Best practices for using CVarSMRTTexelDitherScaleLocal include:

  1. Accessing its value using GetValueOnRenderThread() when needed in render thread operations.
  2. Considering caching the value if it’s accessed frequently to avoid potential performance overhead from repeated console variable lookups.
  3. Being cautious when modifying this variable directly, as it’s typically managed by the console variable 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:99

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarSMRTTexelDitherScaleLocal(
	TEXT( "r.Shadow.Virtual.SMRT.TexelDitherScaleLocal" ),
	2.0f,
	TEXT( "Applies a dither to the shadow map ray casts for local lights to help hide aliasing due to insufficient shadow resolution.\n" )
	TEXT( "Setting this too high can cause shadows light leaks near occluders." ),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<float> CVarSMRTTexelDitherScaleLocal(
	TEXT( "r.Shadow.Virtual.SMRT.TexelDitherScaleLocal" ),
	2.0f,
	TEXT( "Applies a dither to the shadow map ray casts for local lights to help hide aliasing due to insufficient shadow resolution.\n" )
	TEXT( "Setting this too high can cause shadows light leaks near occluders." ),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
function     FVirtualShadowMapSMRTSettings GetVirtualShadowMapSMRTSettings

Source code excerpt:

		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;
}