r.KeepPreCulledIndicesThreshold
r.KeepPreCulledIndicesThreshold
#Overview
name: r.KeepPreCulledIndicesThreshold
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.KeepPreCulledIndicesThreshold is to control the threshold for keeping pre-culled indices in static mesh components. This setting is part of the rendering optimization system in Unreal Engine 5.
The Unreal Engine subsystem that relies on this setting variable is the rendering system, specifically the static mesh component rendering optimization. It is used within the Engine module, as evidenced by its location in the StaticMeshComponent.cpp file.
The value of this variable is set through the console variable system, as indicated by the FAutoConsoleVariableRef declaration. It can be changed at runtime using console commands or through configuration files.
The associated variable GKeepPreCulledIndicesThreshold interacts directly with r.KeepPreCulledIndicesThreshold. They share the same value, with GKeepPreCulledIndicesThreshold being the actual float variable used in the code.
Developers must be aware that this variable affects the memory usage and rendering performance of static mesh components. It determines when to keep pre-culled index buffers based on the ratio of visible triangles to original triangles.
Best practices when using this variable include:
- Adjusting it carefully to balance between memory usage and rendering performance.
- Testing different values to find the optimal threshold for your specific use case.
- Considering the impact on different hardware configurations, as it’s marked with ECVF_Scalability.
Regarding the associated variable GKeepPreCulledIndicesThreshold:
The purpose of GKeepPreCulledIndicesThreshold is to store the actual float value used in the static mesh component optimization logic.
It is used directly in the UStaticMeshComponent::UpdatePreCulledData function to determine whether to keep pre-culled indices for a specific LOD.
The value is set initially to 0.95f, but can be modified through the r.KeepPreCulledIndicesThreshold console variable.
This variable interacts with the rendering system by influencing the decision to keep or discard pre-culled index buffers for static mesh components.
Developers should be aware that modifying this value directly in code is not recommended, as it’s intended to be controlled through the console variable system.
Best practices for GKeepPreCulledIndicesThreshold include:
- Avoiding direct modification in code unless absolutely necessary.
- Using the r.KeepPreCulledIndicesThreshold console variable for adjustments.
- Monitoring its impact on rendering performance and memory usage when changes are made.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/StaticMeshComponent.cpp:1775
Scope: file
Source code excerpt:
FAutoConsoleVariableRef CKeepPreCulledIndicesThreshold(
TEXT("r.KeepPreCulledIndicesThreshold"),
GKeepPreCulledIndicesThreshold,
TEXT(""),
ECVF_Scalability | ECVF_RenderThreadSafe
);
void UStaticMeshComponent::UpdatePreCulledData(int32 LODIndex, const TArray<uint32>& PreCulledData, const TArray<int32>& NumTrianglesPerSection)
#Associated Variable and Callsites
This variable is associated with another variable named GKeepPreCulledIndicesThreshold
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/StaticMeshComponent.cpp:1772
Scope: file
Source code excerpt:
#endif // WITH_EDITOR
float GKeepPreCulledIndicesThreshold = .95f;
FAutoConsoleVariableRef CKeepPreCulledIndicesThreshold(
TEXT("r.KeepPreCulledIndicesThreshold"),
GKeepPreCulledIndicesThreshold,
TEXT(""),
ECVF_Scalability | ECVF_RenderThreadSafe
);
void UStaticMeshComponent::UpdatePreCulledData(int32 LODIndex, const TArray<uint32>& PreCulledData, const TArray<int32>& NumTrianglesPerSection)
{
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/StaticMeshComponent.cpp:1795
Scope (from outer to inner):
file
function void UStaticMeshComponent::UpdatePreCulledData
Source code excerpt:
}
if (NumVisibleTriangles / (float)NumOriginalTriangles < GKeepPreCulledIndicesThreshold)
{
SetLODDataCount(LODIndex + 1, LODData.Num());
DEC_DWORD_STAT_BY(STAT_StaticMeshPreCulledIndexMemory, LODData[LODIndex].PreCulledIndexBuffer.GetAllocatedSize());
//@todo - game thread
check(IsInRenderingThread());