r.DFShadowCullTileWorldSize

r.DFShadowCullTileWorldSize

#Overview

name: r.DFShadowCullTileWorldSize

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.DFShadowCullTileWorldSize is to define the world space size of a tile used for culling directional lights in the distance field shadowing system. This setting is part of Unreal Engine 5’s rendering system, specifically the distance field shadowing subsystem.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the distance field shadowing component. This can be inferred from the file path where the variable is defined: “Engine/Source/Runtime/Renderer/Private/DistanceFieldShadowing.cpp”.

The value of this variable is set using the FAutoConsoleVariableRef mechanism, which allows it to be changed at runtime through console commands. The default value is 200.0f.

This variable interacts directly with its associated variable GShadowCullTileWorldSize. They share the same value, with r.DFShadowCullTileWorldSize being the console-accessible name and GShadowCullTileWorldSize being the actual C++ variable used in the code.

Developers must be aware that this variable affects the performance and quality of distance field shadows for directional lights. Changing this value will impact the size of tiles used for culling objects in the distance field shadow calculation.

Best practices when using this variable include:

  1. Adjusting it for performance optimization, especially in scenes with many objects casting distance field shadows.
  2. Being cautious about setting it too high, as it might reduce culling efficiency.
  3. Testing different values to find the right balance between performance and shadow quality for your specific scene.

Regarding the associated variable GShadowCullTileWorldSize:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldShadowing.cpp:67

Scope: file

Source code excerpt:

float GShadowCullTileWorldSize = 200.0f;
FAutoConsoleVariableRef CVarShadowCullTileWorldSize(
	TEXT("r.DFShadowCullTileWorldSize"),
	GShadowCullTileWorldSize,
	TEXT("World space size of a tile used for culling for directional lights."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GDFShadowTwoSidedMeshDistanceBiasScale = 1.0f;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldShadowing.cpp:65

Scope: file

Source code excerpt:

	);

float GShadowCullTileWorldSize = 200.0f;
FAutoConsoleVariableRef CVarShadowCullTileWorldSize(
	TEXT("r.DFShadowCullTileWorldSize"),
	GShadowCullTileWorldSize,
	TEXT("World space size of a tile used for culling for directional lights."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GDFShadowTwoSidedMeshDistanceBiasScale = 1.0f;
FAutoConsoleVariableRef CVarShadowTwoSidedMeshDistanceBiasScale(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldShadowing.cpp:623

Scope (from outer to inner):

file
function     void CullDistanceFieldObjectsForLight

Source code excerpt:

	{
		// Allocate tile resolution based on world space size
		const float LightTiles = FMath::Min(ShadowBoundingRadius / GShadowCullTileWorldSize + 1.0f, 256.0f);
		FIntPoint LightTileDimensions(Align(FMath::TruncToInt(LightTiles), 64), Align(FMath::TruncToInt(LightTiles), 64));

		const bool b16BitObjectIndices = Scene->DistanceFieldSceneData.CanUse16BitObjectIndices();

		FRDGBufferRef ShadowTileNumCulledObjects = GraphBuilder.CreateBuffer(FRDGBufferDesc::CreateBufferDesc(sizeof(uint32), LightTileDimensions.X * LightTileDimensions.Y), TEXT("ShadowTileNumCulledObjects"));
		LightTileIntersectionParameters.RWShadowTileNumCulledObjects = GraphBuilder.CreateUAV(ShadowTileNumCulledObjects, PF_R32_UINT);