foliage.DisableCull

foliage.DisableCull

#Overview

name: foliage.DisableCull

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 foliage.DisableCull is to control the culling behavior of foliage in Unreal Engine 5’s rendering system. It is specifically used to disable frustum-based culling for foliage instances when its value is greater than zero.

This setting variable is primarily used in the Engine module, particularly in the Hierarchical Instanced Static Mesh component, which is a crucial part of Unreal Engine’s foliage rendering system.

The value of this variable is set through a console variable (CVar) named CVarDisableCull. It is initialized with a default value of 0, meaning culling is enabled by default. Developers can change this value at runtime using console commands or through code.

The associated variable CVarDisableCull directly interacts with foliage.DisableCull. They share the same value and purpose. CVarDisableCull is the actual TAutoConsoleVariable object that holds and manages the value of foliage.DisableCull.

Developers must be aware that disabling culling can significantly impact performance, especially in scenes with dense foliage. When this variable is set to a value greater than zero, all foliage instances will be rendered regardless of whether they are in the camera’s view frustum or not.

Best practices when using this variable include:

  1. Keep it disabled (set to 0) for production builds to maintain optimal performance.
  2. Use it judiciously during development for debugging or specific visual checks.
  3. Be cautious when enabling it in large scenes with extensive foliage, as it may cause performance issues.
  4. Consider using it in conjunction with other foliage-related settings for comprehensive debugging or specific visual effects.

Regarding the associated variable CVarDisableCull:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/HierarchicalInstancedStaticMesh.cpp:55

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDisableCull(
	TEXT("foliage.DisableCull"),
	0,
	TEXT("If greater than zero, no culling occurs based on frustum."));

static TAutoConsoleVariable<int32> CVarCullAll(
	TEXT("foliage.CullAll"),
	0,

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/HierarchicalInstancedStaticMesh.cpp:54

Scope: file

Source code excerpt:

	TEXT("If greater than or equal to zero, only renders the foliage LOD at that level."));

static TAutoConsoleVariable<int32> CVarDisableCull(
	TEXT("foliage.DisableCull"),
	0,
	TEXT("If greater than zero, no culling occurs based on frustum."));

static TAutoConsoleVariable<int32> CVarCullAll(
	TEXT("foliage.CullAll"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/HierarchicalInstancedStaticMesh.cpp:1532

Scope (from outer to inner):

file
function     void FHierarchicalStaticMeshSceneProxy::GetDynamicMeshElements

Source code excerpt:

				bool bIsOrtho = false;

				bool bDisableCull = !!CVarDisableCull.GetValueOnRenderThread();
				ElementParams.ShadowFrustum = !!View->GetDynamicMeshElementsShadowCullFrustum();
				if (View->GetDynamicMeshElementsShadowCullFrustum())
				{
					for (int32 Index = 0; Index < View->GetDynamicMeshElementsShadowCullFrustum()->Planes.Num(); Index++)
					{
						FPlane Src = View->GetDynamicMeshElementsShadowCullFrustum()->Planes[Index];