r.Shadow.Virtual.Clipmap.WPODisableDistance

r.Shadow.Virtual.Clipmap.WPODisableDistance

#Overview

name: r.Shadow.Virtual.Clipmap.WPODisableDistance

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.Clipmap.WPODisableDistance is to control the disabling of World Position Offset (WPO) animation in clipmap levels for virtual shadow maps. This setting is part of the rendering system, specifically related to shadow rendering and optimization.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the Virtual Shadow Maps subsystem. It’s referenced in the VirtualShadowMapClipmap.cpp file, which suggests it’s closely tied to the implementation of virtual shadow map clipmaps.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning the feature is enabled by default. Developers can modify this value at runtime or through configuration files.

This variable interacts with another related variable, CVarClipmapWPODisableDistanceLodBias. Together, they determine when to disable WPO animation based on a primitive’s WPO disable distance and the LOD bias setting.

Developers should be aware that this variable affects performance and visual quality. Enabling this feature (value > 0) can potentially improve performance by reducing the need to update shadow maps for objects with world position offset animations at certain distances.

Best practices for using this variable include:

  1. Carefully balancing performance gains against visual quality.
  2. Testing different values to find the optimal setting for your specific game or application.
  3. Considering the interaction with the WPODisableDistanceLodBias setting for fine-tuning.

Regarding the associated variable CVarClipmapWPODisableDistance:

The purpose of CVarClipmapWPODisableDistance is identical to r.Shadow.Virtual.Clipmap.WPODisableDistance, as they share the same value and functionality.

This variable is used directly in the code to check if the WPO disable distance feature is enabled. It’s accessed in the FVirtualShadowMapClipmap constructor, where it determines whether to calculate and set the WPODistanceDisableThresholdSquared for each clipmap level.

The value is retrieved using the GetValueOnRenderThread() method, indicating that it’s designed to be safely accessed from the render thread.

Developers should be aware that this variable directly affects the behavior of virtual shadow map clipmaps and can impact both performance and visual quality.

Best practices for using CVarClipmapWPODisableDistance include:

  1. Coordinating its use with other shadow and rendering settings for optimal results.
  2. Profiling the impact on performance and visual quality when modifying this value.
  3. Considering the needs of different hardware capabilities when setting this value, as it can affect performance on varying systems differently.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapClipmap.cpp:79

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarClipmapWPODisableDistance(
	TEXT("r.Shadow.Virtual.Clipmap.WPODisableDistance"),
	1,
	TEXT("When enabled, disables WPO animation in clipmap levels based on a primitive's WPO disable distance and r.Shadow.Virtual.Clipmap.WPODisableDistance.LodBias setting."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarClipmapWPODisableDistanceLodBias(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapClipmap.cpp:78

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarClipmapWPODisableDistance(
	TEXT("r.Shadow.Virtual.Clipmap.WPODisableDistance"),
	1,
	TEXT("When enabled, disables WPO animation in clipmap levels based on a primitive's WPO disable distance and r.Shadow.Virtual.Clipmap.WPODisableDistance.LodBias setting."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapClipmap.cpp:336

Scope (from outer to inner):

file
function     FVirtualShadowMapClipmap::FVirtualShadowMapClipmap

Source code excerpt:

		// We quantize the result to a powers of two (similar to the clipmaps) to avoid continuous invalidation in
		// cases like window resizes and similar.
		if (CVarClipmapWPODisableDistance.GetValueOnRenderThread() > 0)
		{
			const int32 WPODisableDistanceLodBias = CVarClipmapWPODisableDistanceLodBias.GetValueOnRenderThread();
			double WPOThresholdCombinedLevel = FMath::CeilToDouble(static_cast<double>(AbsoluteLevel - WPODisableDistanceLodBias) - ResolutionLodBias);
			// NOTE: Squared
			Level.WPODistanceDisableThresholdSquared = FMath::Pow(2.0, 2.0 * WPOThresholdCombinedLevel);
		}