r.SceneCulling.TreatInstancedDynamicAsUnCullable

r.SceneCulling.TreatInstancedDynamicAsUnCullable

#Overview

name: r.SceneCulling.TreatInstancedDynamicAsUnCullable

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.TreatInstancedDynamicAsUnCullable is to control how dynamic primitives with instances are treated in the scene culling process. This setting variable is part of Unreal Engine 5’s rendering system, specifically the scene culling subsystem.

Based on the details in the Callsites section, this variable is primarily used in the Renderer module, particularly in the SceneCulling.cpp file. This suggests that the scene culling system heavily relies on this setting.

The value of this variable is set through a console variable (CVarTreatDynamicInstancedAsUncullable) with a default value of 1 (enabled). It can be changed at runtime through console commands or project settings.

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

Developers must be aware that when this variable is enabled (which is the default state), dynamic primitives with instances are treated as uncullable. This means they are not put into the culling hierarchy but are instead processed directly on the GPU. This can significantly reduce the CPU cost of updating the culling hierarchy, especially in scenes with a large proportion of static elements.

Best practices when using this variable include:

  1. Leave it enabled (default) for most scenarios, as it can improve performance.
  2. Consider disabling it if you have a scene with a very high number of dynamic instanced primitives and relatively few static elements, as this might lead to unnecessary GPU processing.
  3. Profile your game with this setting both enabled and disabled to determine which configuration provides better performance for your specific use case.

Regarding the associated variable CVarTreatDynamicInstancedAsUncullable:

#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:149

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarTreatDynamicInstancedAsUncullable(
	TEXT("r.SceneCulling.TreatInstancedDynamicAsUnCullable"), 
	1, 
	TEXT("If this is turned on (default), dynamic primitives with instances are treated as uncullable (not put into the hierarchy and instead brute-forced on the GPU).")
	TEXT("  This significantly reduces the hierarchy update cost on the CPU and for scenes with a large proportion of static elements, does not increase the GPU cost."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarSmallFootprintSideThreshold(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_ReadOnly);

static TAutoConsoleVariable<int32> CVarTreatDynamicInstancedAsUncullable(
	TEXT("r.SceneCulling.TreatInstancedDynamicAsUnCullable"), 
	1, 
	TEXT("If this is turned on (default), dynamic primitives with instances are treated as uncullable (not put into the hierarchy and instead brute-forced on the GPU).")
	TEXT("  This significantly reduces the hierarchy update cost on the CPU and for scenes with a large proportion of static elements, does not increase the GPU cost."),
	ECVF_RenderThreadSafe);

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

Scope (from outer to inner):

file
class        class FSceneCullingBuilder
function     FSceneCullingBuilder

Source code excerpt:

		bUsePrecomputed = CVarSceneCullingPrecomputed.GetValueOnAnyThread() != 0;

		if (CVarTreatDynamicInstancedAsUncullable.GetValueOnRenderThread() != 0)
		{
			// Flip dynamic stuff into the uncullabe bucket. 
			DynamicInstancedPrimitiveState = FPrimitiveState::UnCullable;
		}

#if SC_ENABLE_DETAILED_LOGGING