r.Nanite.ViewMeshLODBias.Enable
r.Nanite.ViewMeshLODBias.Enable
#Overview
name: r.Nanite.ViewMeshLODBias.Enable
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether LOD offset to apply for rasterized Nanite meshes for the main viewport should be based off TSR\'s ScreenPercentage (Enabled by default).
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Nanite.ViewMeshLODBias.Enable is to control whether the Level of Detail (LOD) offset for rasterized Nanite meshes in the main viewport should be based on Temporal Super Resolution’s (TSR) ScreenPercentage.
This setting variable is primarily used in the rendering system, specifically for Nanite, Unreal Engine 5’s virtualized geometry system. It is referenced in the DeferredShadingRenderer module, which is a core part of Unreal Engine’s rendering pipeline.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 (enabled) in the C++ code.
This variable interacts closely with other Nanite-related variables, particularly:
- r.Nanite.ViewMeshLODBias.Offset (CVarNaniteViewMeshLODBiasOffset)
- r.Nanite.ViewMeshLODBias.Min (CVarNaniteViewMeshLODBiasMin)
Developers must be aware that this setting affects the visual quality and performance of Nanite meshes. When enabled, it allows for dynamic LOD adjustment based on the screen percentage used by TSR, which can help maintain visual quality when using temporal upscaling techniques.
Best practices when using this variable include:
- Keep it enabled (default setting) when using TSR to ensure consistent visual quality across different resolutions.
- If disabling, carefully consider the impact on visual quality, especially in scenarios with dynamic resolution scaling.
- Use in conjunction with r.Nanite.ViewMeshLODBias.Offset to fine-tune the LOD bias.
Regarding the associated variable CVarNaniteViewMeshLODBiasEnable:
The purpose of CVarNaniteViewMeshLODBiasEnable is to serve as the internal representation of the r.Nanite.ViewMeshLODBias.Enable console variable within the C++ code.
This variable is used directly in the rendering system, specifically in the FDeferredShadingSceneRenderer::RenderNanite function. It’s part of the Renderer module in Unreal Engine.
The value of this variable is set through the CVar system and can be accessed at runtime using the GetValueOnRenderThread() method.
CVarNaniteViewMeshLODBiasEnable interacts with other variables like CVarNaniteViewMeshLODBiasOffset and CVarNaniteViewMeshLODBiasMin to determine the final LOD scale factor for Nanite meshes.
Developers should be aware that this variable is checked in the render thread, so any changes to it will affect rendering in real-time.
Best practices for using this variable include:
- Use it for conditional logic in rendering code related to Nanite LOD biasing.
- Be cautious when modifying its value at runtime, as it can impact rendering performance and quality.
- Consider its interaction with TSR and other Nanite-related settings when optimizing rendering.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:237
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarNaniteViewMeshLODBiasEnable(
TEXT("r.Nanite.ViewMeshLODBias.Enable"), 1,
TEXT("Whether LOD offset to apply for rasterized Nanite meshes for the main viewport should be based off TSR's ScreenPercentage (Enabled by default)."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarNaniteViewMeshLODBiasOffset(
TEXT("r.Nanite.ViewMeshLODBias.Offset"), 0.0f,
TEXT("LOD offset to apply for rasterized Nanite meshes for the main viewport when using TSR (Default = 0)."),
#Associated Variable and Callsites
This variable is associated with another variable named CVarNaniteViewMeshLODBiasEnable
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:236
Scope: file
Source code excerpt:
#endif
static TAutoConsoleVariable<int32> CVarNaniteViewMeshLODBiasEnable(
TEXT("r.Nanite.ViewMeshLODBias.Enable"), 1,
TEXT("Whether LOD offset to apply for rasterized Nanite meshes for the main viewport should be based off TSR's ScreenPercentage (Enabled by default)."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarNaniteViewMeshLODBiasOffset(
TEXT("r.Nanite.ViewMeshLODBias.Offset"), 0.0f,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:1368
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderNanite
Source code excerpt:
float LODScaleFactor = 1.0f;
if (View.PrimaryScreenPercentageMethod == EPrimaryScreenPercentageMethod::TemporalUpscale &&
CVarNaniteViewMeshLODBiasEnable.GetValueOnRenderThread() != 0)
{
float TemporalUpscaleFactor = float(View.GetSecondaryViewRectSize().X) / float(ViewRect.Width());
LODScaleFactor = TemporalUpscaleFactor * FMath::Exp2(-CVarNaniteViewMeshLODBiasOffset.GetValueOnRenderThread());
LODScaleFactor = FMath::Min(LODScaleFactor, FMath::Exp2(-CVarNaniteViewMeshLODBiasMin.GetValueOnRenderThread()));
}