r.Nanite.Builder.FallbackTriangleThreshold
r.Nanite.Builder.FallbackTriangleThreshold
#Overview
name: r.Nanite.Builder.FallbackTriangleThreshold
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Triangle count <= to this threshold uses the source mesh unchanged as the fallback.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Nanite.Builder.FallbackTriangleThreshold is to set a threshold for the number of triangles in a mesh, below which the source mesh is used unchanged as the fallback mesh in Nanite, Unreal Engine 5’s virtualized geometry system.
This setting variable is primarily used by the Nanite Builder subsystem, which is part of the MeshBuilder module in Unreal Engine 5. It’s specifically utilized in the process of building Nanite-enabled meshes and determining fallback settings for these meshes.
The value of this variable is set as a console variable, which means it can be adjusted at runtime or set in configuration files. It’s defined with a default value of 0 and is marked as read-only (ECVF_ReadOnly).
The associated variable CVarFallbackThreshold interacts directly with r.Nanite.Builder.FallbackTriangleThreshold. It’s used to retrieve the current value of the setting in the code.
Developers should be aware that this variable significantly affects how Nanite handles small meshes. When a mesh has a triangle count less than or equal to this threshold, Nanite will use the original mesh as the fallback without any simplification.
Best practices when using this variable include:
- Setting it to an appropriate value based on your project’s requirements for small mesh handling.
- Being aware that setting it too high might impact performance by preventing simplification of larger meshes.
- Understanding that a value of 0 (the default) means all meshes will be processed by Nanite without using the source mesh as a fallback.
Regarding the associated variable CVarFallbackThreshold:
- Its purpose is to provide easy access to the r.Nanite.Builder.FallbackTriangleThreshold value within the C++ code.
- It’s used in the MeshBuilder and NaniteBuilder modules.
- Its value is set automatically based on the r.Nanite.Builder.FallbackTriangleThreshold console variable.
- It’s used to determine fallback settings for Nanite meshes and is part of the Nanite build version string.
- Developers should be aware that any changes to r.Nanite.Builder.FallbackTriangleThreshold will be reflected in CVarFallbackThreshold.
- Best practice is to use CVarFallbackThreshold for reading the value in C++ code, rather than directly accessing the console variable.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Developer/NaniteBuilder/Private/NaniteBuilder.cpp:34
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarFallbackThreshold(
TEXT("r.Nanite.Builder.FallbackTriangleThreshold"),
0,
TEXT("Triangle count <= to this threshold uses the source mesh unchanged as the fallback."),
ECVF_ReadOnly );
namespace Nanite
{
#Loc: <Workspace>/Engine/Source/Developer/MeshBuilder/Private/StaticMeshBuilder.cpp:102
Scope (from outer to inner):
file
function static void CorrectFallbackSettings
Source code excerpt:
static void CorrectFallbackSettings( FMeshNaniteSettings& NaniteSettings, int32 NumTris )
{
static const auto CVarFallbackThreshold = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Nanite.Builder.FallbackTriangleThreshold"));
switch( NaniteSettings.FallbackTarget )
{
case ENaniteFallbackTarget::Auto:
NaniteSettings.FallbackPercentTriangles = 1.0f;
NaniteSettings.FallbackRelativeError = NumTris <= CVarFallbackThreshold->GetValueOnAnyThread() ? 0.0f : 1.0f;
#Associated Variable and Callsites
This variable is associated with another variable named CVarFallbackThreshold
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Developer/MeshBuilder/Private/StaticMeshBuilder.cpp:102
Scope (from outer to inner):
file
function static void CorrectFallbackSettings
Source code excerpt:
static void CorrectFallbackSettings( FMeshNaniteSettings& NaniteSettings, int32 NumTris )
{
static const auto CVarFallbackThreshold = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Nanite.Builder.FallbackTriangleThreshold"));
switch( NaniteSettings.FallbackTarget )
{
case ENaniteFallbackTarget::Auto:
NaniteSettings.FallbackPercentTriangles = 1.0f;
NaniteSettings.FallbackRelativeError = NumTris <= CVarFallbackThreshold->GetValueOnAnyThread() ? 0.0f : 1.0f;
break;
case ENaniteFallbackTarget::PercentTriangles:
NaniteSettings.FallbackRelativeError = 0.0f;
break;
case ENaniteFallbackTarget::RelativeError:
NaniteSettings.FallbackPercentTriangles = 1.0f;
#Loc: <Workspace>/Engine/Source/Developer/NaniteBuilder/Private/NaniteBuilder.cpp:33
Scope: file
Source code excerpt:
#endif
static TAutoConsoleVariable<int32> CVarFallbackThreshold(
TEXT("r.Nanite.Builder.FallbackTriangleThreshold"),
0,
TEXT("Triangle count <= to this threshold uses the source mesh unchanged as the fallback."),
ECVF_ReadOnly );
namespace Nanite
#Loc: <Workspace>/Engine/Source/Developer/NaniteBuilder/Private/NaniteBuilder.cpp:87
Scope (from outer to inner):
file
namespace Nanite
function const FString& FBuilderModule::GetVersionString
Source code excerpt:
bBuildImposters ? TEXT("_IMPOSTERS") : TEXT(""));
VersionString.Appendf( TEXT("%i"), CVarFallbackThreshold.GetValueOnAnyThread() );
#if NANITE_STRIP_DATA
VersionString.Append(TEXT("_STRIP"));
#endif
#if PLATFORM_CPU_ARM_FAMILY