r.Nanite.ImposterMaxPixels
r.Nanite.ImposterMaxPixels
#Overview
name: r.Nanite.ImposterMaxPixels
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The maximum size of imposters measured in pixels.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Nanite.ImposterMaxPixels is to control the maximum size of imposters in the Nanite rendering system, measured in pixels. This setting is crucial for optimizing the rendering performance and visual quality of Nanite-powered geometry in Unreal Engine 5.
This setting variable is primarily used by the Nanite subsystem within the Unreal Engine 5 renderer. Specifically, it’s utilized in the Nanite culling and rasterization processes, as evidenced by its presence in the NaniteCullRaster.cpp file.
The value of this variable is set using a console variable (CVar) system. It’s defined as a static TAutoConsoleVariable with a default value of 5 pixels. This means that by default, Nanite imposters will have a maximum size of 5 pixels.
The associated variable CVarNaniteImposterMaxPixels interacts directly with r.Nanite.ImposterMaxPixels. They share the same value and purpose, with CVarNaniteImposterMaxPixels being the actual C++ variable used in the code to access the console variable’s value.
Developers should be aware that changing this value can affect both performance and visual quality. A lower value may improve performance but could potentially reduce visual fidelity, especially for distant objects. Conversely, a higher value may improve visual quality at the cost of performance.
Best practices when using this variable include:
- Testing different values to find the optimal balance between performance and visual quality for your specific project.
- Considering the target hardware when setting this value, as more powerful systems may be able to handle larger imposter sizes.
- Using this in conjunction with other Nanite settings for a comprehensive optimization strategy.
Regarding the associated variable CVarNaniteImposterMaxPixels:
- Its purpose is to provide programmatic access to the r.Nanite.ImposterMaxPixels console variable within the C++ code.
- It’s used in the Nanite renderer subsystem, specifically in the instance hierarchy and cluster culling pass.
- Its value is set by the console variable system and retrieved using the GetValueOnRenderThread() method.
- It directly interacts with r.Nanite.ImposterMaxPixels, essentially serving as its in-code representation.
- Developers should be aware that this variable is used in performance-critical rendering code and should be cautious about frequently changing its value during runtime.
- Best practices include caching the value if it’s used frequently in a single frame, rather than calling GetValueOnRenderThread() multiple times.
#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:146
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarNaniteImposterMaxPixels(
TEXT("r.Nanite.ImposterMaxPixels"),
5,
TEXT("The maximum size of imposters measured in pixels."),
ECVF_RenderThreadSafe
);
TAutoConsoleVariable<float> CVarNaniteMinPixelsPerEdgeHW(
#Associated Variable and Callsites
This variable is associated with another variable named CVarNaniteImposterMaxPixels
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:145
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarNaniteImposterMaxPixels(
TEXT("r.Nanite.ImposterMaxPixels"),
5,
TEXT("The maximum size of imposters measured in pixels."),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:3441
Scope (from outer to inner):
file
namespace Nanite
function void FRenderer::AddPass_InstanceHierarchyAndClusterCull
lambda-function
Source code excerpt:
PassParameters->NumInstances = NumInstancesPreCull;
PassParameters->MaxNodes = Nanite::FGlobalResources::GetMaxNodes();
PassParameters->ImposterMaxPixels = CVarNaniteImposterMaxPixels.GetValueOnRenderThread();
PassParameters->Scene = SceneUniformBuffer;
PassParameters->RasterParameters = RasterContext.Parameters;
PassParameters->CullingParameters = CullingParameters;
PassParameters->ImposterAtlas = Nanite::GStreamingManager.GetImposterDataSRV(GraphBuilder);