r.Nanite.ViewMeshLODBias.Min

r.Nanite.ViewMeshLODBias.Min

#Overview

name: r.Nanite.ViewMeshLODBias.Min

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Nanite.ViewMeshLODBias.Min is to set the minimum LOD (Level of Detail) offset for rasterizing Nanite meshes in the main viewport of Unreal Engine 5. This setting is part of the Nanite geometry system, which is a core component of UE5’s rendering pipeline.

This setting variable is primarily used by the rendering system, specifically the Nanite subsystem within Unreal Engine 5. Based on the callsites, it’s clear that this variable is utilized in the DeferredShadingRenderer module, which is responsible for the deferred rendering technique used in UE5.

The value of this variable is set as a console variable (CVar) with a default value of -2.0. It can be modified at runtime through the console or configuration files.

The associated variable CVarNaniteViewMeshLODBiasMin interacts directly with r.Nanite.ViewMeshLODBias.Min. They share the same value and purpose, with CVarNaniteViewMeshLODBiasMin being the C++ representation of the console variable.

Developers should be aware that this variable affects the LOD calculation for Nanite meshes. A lower value allows for higher detail meshes to be rendered at greater distances, potentially impacting performance. Conversely, a higher value will reduce detail but may improve performance.

Best practices when using this variable include:

  1. Carefully adjusting the value to balance between visual quality and performance.
  2. Testing the impact of different values in various scenarios, especially in performance-critical areas of the game.
  3. Considering the target hardware when setting this value, as lower-end devices may benefit from a higher minimum bias.

Regarding the associated variable CVarNaniteViewMeshLODBiasMin:

The purpose of CVarNaniteViewMeshLODBiasMin is to provide a C++ interface for the r.Nanite.ViewMeshLODBias.Min console variable. It allows the engine to access and modify the minimum LOD bias for Nanite meshes programmatically.

This variable is used within the rendering system, specifically in the DeferredShadingRenderer module. It’s accessed in the RenderNanite function, which is part of the FDeferredShadingSceneRenderer class.

The value of CVarNaniteViewMeshLODBiasMin is set when the console variable r.Nanite.ViewMeshLODBias.Min is initialized or modified.

CVarNaniteViewMeshLODBiasMin interacts directly with r.Nanite.ViewMeshLODBias.Min, as they represent the same setting. It’s also used in calculations involving other variables like CVarNaniteViewMeshLODBiasOffset and LODScaleFactor.

Developers should be aware that this variable is accessed on the render thread (GetValueOnRenderThread()), which is important for thread safety in multi-threaded rendering scenarios.

Best practices for using CVarNaniteViewMeshLODBiasMin include:

  1. Accessing it only on the render thread to avoid potential race conditions.
  2. Using it in conjunction with other Nanite-related settings for comprehensive LOD management.
  3. Considering its impact on both visual quality and performance when modifying its value programmatically.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:247

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarNaniteViewMeshLODBiasMin(
	TEXT("r.Nanite.ViewMeshLODBias.Min"), -2.0f,
	TEXT("Minimum LOD offset for rasterizing Nanite meshes for the main viewport (Default = -2)."),
	ECVF_RenderThreadSafe);

namespace Lumen
{
	extern bool AnyLumenHardwareRayTracingPassEnabled();

#Associated Variable and Callsites

This variable is associated with another variable named CVarNaniteViewMeshLODBiasMin. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:246

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarNaniteViewMeshLODBiasMin(
	TEXT("r.Nanite.ViewMeshLODBias.Min"), -2.0f,
	TEXT("Minimum LOD offset for rasterizing Nanite meshes for the main viewport (Default = -2)."),
	ECVF_RenderThreadSafe);

namespace Lumen
{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:1373

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderNanite

Source code excerpt:


				LODScaleFactor = TemporalUpscaleFactor * FMath::Exp2(-CVarNaniteViewMeshLODBiasOffset.GetValueOnRenderThread());
				LODScaleFactor = FMath::Min(LODScaleFactor, FMath::Exp2(-CVarNaniteViewMeshLODBiasMin.GetValueOnRenderThread()));
			}

			float MaxPixelsPerEdgeMultipler = 1.0f / LODScaleFactor;
			if (GDynamicNaniteScalingPrimary.GetSettings().IsEnabled())
			{
				MaxPixelsPerEdgeMultipler *= 1.0f / DynamicResolutionFractions[GDynamicNaniteScalingPrimary];