r.DFShadowScatterTileCulling

r.DFShadowScatterTileCulling

#Overview

name: r.DFShadowScatterTileCulling

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.DFShadowScatterTileCulling is to control whether the rasterizer is used to scatter objects onto a tile grid for culling in distance field shadowing.

This setting variable is primarily used in the rendering system, specifically for distance field shadowing. It’s part of Unreal Engine’s renderer module, as evidenced by its location in the ‘Renderer/Private/DistanceFieldShadowing.cpp’ file.

The Unreal Engine subsystem that relies on this setting variable is the rendering system, particularly the part that handles distance field shadows.

The value of this variable is set through the console variable system. It’s defined as an FAutoConsoleVariableRef, which means it can be changed at runtime through console commands or configuration files.

The associated variable that interacts with r.DFShadowScatterTileCulling is GShadowScatterTileCulling. They share the same value, with GShadowScatterTileCulling being the actual int32 variable used in the code.

Developers must be aware that this variable affects the performance and quality of distance field shadows, particularly for directional lights. When enabled (set to 1), it uses the rasterizer to scatter objects onto a tile grid for culling, which can potentially improve performance.

Best practices when using this variable include:

  1. Testing performance with it both enabled and disabled to determine the best setting for your specific scene.
  2. Consider disabling it if you notice any visual artifacts in distance field shadows.
  3. Be aware that changing this setting may require adjustments to other shadow-related settings for optimal results.

Regarding the associated variable GShadowScatterTileCulling:

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

int32 GShadowScatterTileCulling = 1;
FAutoConsoleVariableRef CVarShadowScatterTileCulling(
	TEXT("r.DFShadowScatterTileCulling"),
	GShadowScatterTileCulling,
	TEXT("Whether to use the rasterizer to scatter objects onto the tile grid for culling."),
	ECVF_RenderThreadSafe
	);

float GShadowCullTileWorldSize = 200.0f;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	);

int32 GShadowScatterTileCulling = 1;
FAutoConsoleVariableRef CVarShadowScatterTileCulling(
	TEXT("r.DFShadowScatterTileCulling"),
	GShadowScatterTileCulling,
	TEXT("Whether to use the rasterizer to scatter objects onto the tile grid for culling."),
	ECVF_RenderThreadSafe
	);

float GShadowCullTileWorldSize = 200.0f;
FAutoConsoleVariableRef CVarShadowCullTileWorldSize(

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

Scope (from outer to inner):

file
function     void CullDistanceFieldObjectsForLight

Source code excerpt:

	}

	if (LightSceneProxy->GetLightType() == LightType_Directional && GShadowScatterTileCulling)
	{
		// 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();

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

Scope (from outer to inner):

file
function     void RayTraceShadows

Source code excerpt:

	EDistanceFieldShadowingType DistanceFieldShadowingType;

	if (ProjectedShadowInfo->bDirectionalLight && GShadowScatterTileCulling)
	{
		DistanceFieldShadowingType = DFS_DirectionalLightScatterTileCulling;
	}
	else if (ProjectedShadowInfo->bDirectionalLight)
	{
		DistanceFieldShadowingType = DFS_DirectionalLightTiledCulling;