r.Nanite.LargePageRectThreshold

r.Nanite.LargePageRectThreshold

#Overview

name: r.Nanite.LargePageRectThreshold

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.Nanite.LargePageRectThreshold is to set a threshold for determining when a candidate cluster in the Nanite system should be considered “large” for statistical purposes. This setting is primarily used in the rendering system, specifically within the Nanite geometry system of Unreal Engine 5.

This setting variable is relied upon by the Nanite subsystem within the Renderer module of Unreal Engine 5. It is specifically used in the culling and rasterization process of Nanite geometry.

The value of this variable is set through the console variable system in Unreal Engine. It is defined with a default value of 128, but can be changed at runtime or through configuration files.

The associated variable CVarLargePageRectThreshold directly interacts with r.Nanite.LargePageRectThreshold. They share the same value and purpose.

Developers must be aware that this variable affects the statistics gathering for Nanite geometry. It determines the threshold at which a cluster is considered “large” based on the number of virtual pages it overlaps. This can impact performance analysis and optimization efforts for Nanite-based rendering.

Best practices when using this variable include:

  1. Adjusting the value based on the specific needs of your project and the scale of your Nanite geometry.
  2. Monitoring performance metrics when changing this value to understand its impact on rendering efficiency.
  3. Using this in conjunction with other Nanite-related settings for comprehensive optimization.

Regarding the associated variable CVarLargePageRectThreshold:

The purpose of CVarLargePageRectThreshold is to provide a programmatic interface to the r.Nanite.LargePageRectThreshold setting within the C++ code of Unreal Engine.

It is used directly in the Nanite rendering code, specifically in the FRenderer::AddPass_NodeAndClusterCull function, where it sets the LargePageRectThreshold parameter for the Nanite culling process.

The value of CVarLargePageRectThreshold is set when the r.Nanite.LargePageRectThreshold console variable is initialized or changed.

Developers should be aware that changes to CVarLargePageRectThreshold will directly affect the Nanite culling process. It’s important to use GetValueOnRenderThread() when accessing this variable to ensure thread-safe operations.

Best practices for CVarLargePageRectThreshold include using it consistently throughout the Nanite rendering code when the large page rect threshold is needed, and ensuring that any modifications to its value are done in a thread-safe manner.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:236

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarLargePageRectThreshold(
	TEXT("r.Nanite.LargePageRectThreshold"),
	128,
	TEXT("Threshold for the size in number of virtual pages overlapped of a candidate cluster to be recorded as large in the stats."),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarNanitePersistentThreadsCulling(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:235

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarLargePageRectThreshold(
	TEXT("r.Nanite.LargePageRectThreshold"),
	128,
	TEXT("Threshold for the size in number of virtual pages overlapped of a candidate cluster to be recorded as large in the stats."),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:3308

Scope (from outer to inner):

file
namespace    Nanite
function     void FRenderer::AddPass_NodeAndClusterCull

Source code excerpt:

	}

	SharedParameters.LargePageRectThreshold = CVarLargePageRectThreshold.GetValueOnRenderThread();
	SharedParameters.StreamingRequestsBufferVersion = GStreamingManager.GetStreamingRequestsBufferVersion();

	check(ViewsBuffer);

	if (CVarNanitePersistentThreadsCulling.GetValueOnRenderThread())
	{