r.Nanite.MaxCandidatePatches
r.Nanite.MaxCandidatePatches
#Overview
name: r.Nanite.MaxCandidatePatches
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Maximum number of Nanite patches considered for splitting.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Nanite.MaxCandidatePatches is to control the maximum number of Nanite patches considered for splitting in the Unreal Engine 5 rendering system. This setting is specifically related to the Nanite virtualized geometry system, which is a core feature of UE5’s rendering capabilities.
This setting variable is primarily used within the Renderer module of Unreal Engine 5, specifically in the Nanite subsystem. Based on the callsites, it’s clear that this variable is part of the Nanite rendering pipeline.
The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 2 * 1048576 (2,097,152) and can be modified at runtime using console commands or through configuration files.
The associated variable GNaniteMaxCandidatePatches directly interacts with r.Nanite.MaxCandidatePatches. They share the same value, with GNaniteMaxCandidatePatches being the internal C++ representation of the console variable.
Developers must be aware that this variable affects the performance and quality of Nanite geometry rendering. Setting it too low might result in reduced visual quality or pop-in effects, while setting it too high could impact performance.
Best practices when using this variable include:
- Adjusting it based on the target hardware capabilities.
- Balancing it with other Nanite-related settings for optimal performance.
- Profiling the application to determine the best value for specific scenes or use cases.
- Considering the memory implications of increasing this value, as it directly affects the number of patches processed.
Regarding the associated variable GNaniteMaxCandidatePatches:
The purpose of GNaniteMaxCandidatePatches is to provide a C++ accessible version of the r.Nanite.MaxCandidatePatches console variable within the engine’s code.
This variable is used in the Renderer module, specifically in the Nanite subsystem. It’s accessed through the FGlobalResources::GetMaxCandidatePatches() function, which suggests it’s part of the global resource management for Nanite.
The value of GNaniteMaxCandidatePatches is set directly by the console variable system when r.Nanite.MaxCandidatePatches is modified.
As mentioned earlier, it directly interacts with r.Nanite.MaxCandidatePatches, serving as its in-code representation.
Developers should be aware that modifying GNaniteMaxCandidatePatches directly in code is not recommended, as it may be overwritten by the console variable system. Instead, they should use the r.Nanite.MaxCandidatePatches console variable to ensure consistency.
Best practices for using GNaniteMaxCandidatePatches include:
- Accessing it through the provided getter function (FGlobalResources::GetMaxCandidatePatches()) rather than directly.
- Treating it as a read-only value in most cases, relying on the console variable system for modifications.
- Considering its value when implementing custom Nanite-related functionality or optimizations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteShared.cpp:55
Scope: file
Source code excerpt:
int32 GNaniteMaxCandidatePatches = 2 * 1048576;
FAutoConsoleVariableRef CVarNaniteMaxCandidatePatches(
TEXT("r.Nanite.MaxCandidatePatches"),
GNaniteMaxCandidatePatches,
TEXT("Maximum number of Nanite patches considered for splitting."),
ECVF_RenderThreadSafe
);
int32 GNaniteMaxVisiblePatches = 2 * 1048576;
#Associated Variable and Callsites
This variable is associated with another variable named GNaniteMaxCandidatePatches
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteShared.cpp:53
Scope: file
Source code excerpt:
);
int32 GNaniteMaxCandidatePatches = 2 * 1048576;
FAutoConsoleVariableRef CVarNaniteMaxCandidatePatches(
TEXT("r.Nanite.MaxCandidatePatches"),
GNaniteMaxCandidatePatches,
TEXT("Maximum number of Nanite patches considered for splitting."),
ECVF_RenderThreadSafe
);
int32 GNaniteMaxVisiblePatches = 2 * 1048576;
FAutoConsoleVariableRef CVarNaniteMaxVisiblePatches(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteShared.cpp:331
Scope (from outer to inner):
file
namespace Nanite
function uint32 FGlobalResources::GetMaxCandidatePatches
Source code excerpt:
uint32 FGlobalResources::GetMaxCandidatePatches()
{
return GNaniteMaxCandidatePatches;
}
uint32 FGlobalResources::GetMaxVisiblePatches()
{
return GNaniteMaxVisiblePatches;
}