foliage.MinVertsToSplitNode

foliage.MinVertsToSplitNode

#Overview

name: foliage.MinVertsToSplitNode

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 foliage.MinVertsToSplitNode is to control the balance between culling and LOD accuracy versus CPU performance in the Hierarchical Instanced Static Mesh system. This setting is primarily used in the rendering system, specifically for managing foliage and other instanced static meshes.

This setting variable is relied upon by the Engine module, particularly within the Hierarchical Instanced Static Mesh component and its associated scene proxy.

The value of this variable is set using a console variable (CVar) system, with a default value of 8192. It can be modified at runtime through console commands or configuration files.

The associated variable CVarMinVertsToSplitNode directly interacts with foliage.MinVertsToSplitNode, as they share the same value. This CVar is used to access the value in the C++ code.

Developers must be aware that this variable affects the performance and visual quality trade-off for instanced meshes. A higher value will result in more accurate culling and LOD transitions but may increase CPU load, while a lower value will improve CPU performance at the cost of potential visual artifacts.

Best practices when using this variable include:

  1. Adjusting the value based on the complexity of your foliage or instanced meshes.
  2. Profiling the performance impact of different values in your specific use case.
  3. Considering the target hardware capabilities when setting this value.

Regarding the associated variable CVarMinVertsToSplitNode:

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarMinVertsToSplitNode(
	TEXT("foliage.MinVertsToSplitNode"),
	8192,
	TEXT("Controls the accuracy between culling and LOD accuracy and culling and CPU performance."));

static TAutoConsoleVariable<int32> CVarMaxOcclusionQueriesPerComponent(
	TEXT("foliage.MaxOcclusionQueriesPerComponent"),
	16,

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	TEXT("Random distance added to each instance distance to compute LOD."));

static TAutoConsoleVariable<int32> CVarMinVertsToSplitNode(
	TEXT("foliage.MinVertsToSplitNode"),
	8192,
	TEXT("Controls the accuracy between culling and LOD accuracy and culling and CPU performance."));

static TAutoConsoleVariable<int32> CVarMaxOcclusionQueriesPerComponent(
	TEXT("foliage.MaxOcclusionQueriesPerComponent"),

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

Scope (from outer to inner):

file
function     void FHierarchicalStaticMeshSceneProxy::GetDynamicMeshElements

Source code excerpt:

	bool bOverestimate = CVarOverestimateLOD.GetValueOnRenderThread() > 0;

	int32 MinVertsToSplitNode = CVarMinVertsToSplitNode.GetValueOnRenderThread();

	const FMatrix WorldToLocal = GetLocalToWorld().Inverse();

	for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
	{
		if (VisibilityMap & (1 << ViewIndex))

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

Scope (from outer to inner):

file
function     int32 UHierarchicalInstancedStaticMeshComponent::DesiredInstancesPerLeaf

Source code excerpt:

{
	int32 LOD0Verts = GetVertsForLOD(0);
	int32 VertsToSplit = CVarMinVertsToSplitNode.GetValueOnAnyThread();
	if (LOD0Verts)
	{
		return FMath::Clamp(VertsToSplit / LOD0Verts, 1, 1024);
	}
	return 16;
}