r.SceneCulling.MaxCellSize

r.SceneCulling.MaxCellSize

#Overview

name: r.SceneCulling.MaxCellSize

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.SceneCulling.MaxCellSize is to define the maximum cell size for the scene culling hierarchy in Unreal Engine 5’s rendering system. It sets an upper limit on the size of cells used in the spatial partitioning structure for scene culling.

This setting variable is primarily used by the rendering subsystem, specifically the scene culling module. It’s part of the optimization techniques used to efficiently determine which objects should be rendered in a given frame.

The value of this variable is set through a console variable (CVar) system. It’s initialized with the value of UE_OLD_HALF_WORLD_MAX, which is likely a predefined constant representing half the maximum world size in older versions of Unreal Engine.

The associated variable CVarSceneCullingMaxCellSize directly interacts with r.SceneCulling.MaxCellSize. They share the same value and purpose.

Developers must be aware that objects with bounds larger than this maximum cell size will be classified as uncullable. This means they will always be considered for rendering, potentially impacting performance if there are many such large objects.

Best practices when using this variable include:

  1. Carefully consider adjusting this value, as it can significantly impact culling efficiency.
  2. Monitor performance when changing this value, especially in scenes with many large objects.
  3. Use in conjunction with r.SceneCulling.MinCellSize for optimal spatial partitioning.

Regarding the associated variable CVarSceneCullingMaxCellSize:

Developers should note that this variable is part of a larger scene culling system, and changes to it should be made with consideration of the entire culling pipeline and the specific requirements of their scene.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneCulling/SceneCulling.cpp:143

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarSceneCullingMaxCellSize(
	TEXT("r.SceneCulling.MaxCellSize"), 
	UE_OLD_HALF_WORLD_MAX, 
	TEXT("Hierarchy max cell size. Objects with larger bounds will be classified as uncullable."), 
	ECVF_RenderThreadSafe | ECVF_ReadOnly);

static TAutoConsoleVariable<int32> CVarTreatDynamicInstancedAsUncullable(
	TEXT("r.SceneCulling.TreatInstancedDynamicAsUnCullable"), 

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneCulling/SceneCulling.cpp:142

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_ReadOnly);

static TAutoConsoleVariable<float> CVarSceneCullingMaxCellSize(
	TEXT("r.SceneCulling.MaxCellSize"), 
	UE_OLD_HALF_WORLD_MAX, 
	TEXT("Hierarchy max cell size. Objects with larger bounds will be classified as uncullable."), 
	ECVF_RenderThreadSafe | ECVF_ReadOnly);

static TAutoConsoleVariable<int32> CVarTreatDynamicInstancedAsUncullable(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneCulling/SceneCulling.cpp:2627

Scope (from outer to inner):

file
function     FSceneCulling::FSceneCulling

Source code excerpt:

	: Scene(InScene)
	, bIsEnabled(UseSceneCulling(Scene.GetShaderPlatform()))
	, SpatialHash( CVarSceneCullingMinCellSize.GetValueOnAnyThread(), CVarSceneCullingMaxCellSize.GetValueOnAnyThread())
	, CellHeadersBuffer(16, TEXT("SceneCulling.CellHeaders"))
	, ItemChunksBuffer(16, TEXT("SceneCulling.ItemChunks"))
	, InstanceIdsBuffer(16, TEXT("SceneCulling.Items"))
	, CellBlockDataBuffer(16, TEXT("SceneCulling.CellBlockData"))
	, ExplicitCellBoundsBuffer(16, TEXT("SceneCulling.ExplicitCellBounds"))
{