r.Nanite.Visualize.OverdrawScale

r.Nanite.Visualize.OverdrawScale

#Overview

name: r.Nanite.Visualize.OverdrawScale

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Nanite.Visualize.OverdrawScale is to control the visualization of overdraw in Nanite, Unreal Engine 5’s virtualized geometry system. This setting variable is specifically used for debugging and performance analysis of Nanite-rendered geometry.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically within the Nanite visualization system. It’s also referenced in the Virtual Shadow Map projection system, indicating its relevance to both Nanite rendering and shadow mapping.

The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 15, representing 15% of contribution per pixel evaluation (up to 100%).

The associated variable GNaniteVisualizeOverdrawScale directly interacts with r.Nanite.Visualize.OverdrawScale. They share the same value, with GNaniteVisualizeOverdrawScale being the C++ variable that’s manipulated in the code based on the console variable setting.

Developers should be aware that this variable affects the visualization of Nanite overdraw, which can be crucial for performance optimization. The scale goes from 0 to 100, representing the percentage of contribution per pixel evaluation.

Best practices when using this variable include:

  1. Use it in conjunction with other Nanite visualization tools for a comprehensive understanding of rendering performance.
  2. Adjust the value to find a balance between visibility of overdraw and performance impact of the visualization itself.
  3. Remember that this is a debugging tool and should be disabled in release builds.

Regarding the associated variable GNaniteVisualizeOverdrawScale:

The purpose of GNaniteVisualizeOverdrawScale is to store and provide access to the overdraw scale value within the C++ code of the Nanite visualization system.

This variable is used in the Renderer module, specifically in the Nanite visualization and Virtual Shadow Map projection systems.

The value of GNaniteVisualizeOverdrawScale is set by the console variable system, mirroring the value of r.Nanite.Visualize.OverdrawScale.

It interacts directly with r.Nanite.Visualize.OverdrawScale and is used in calculations for visualization scales and parameters for shader passes.

Developers should be aware that modifying GNaniteVisualizeOverdrawScale directly in code will not persist across console variable changes, as it’s controlled by the console variable system.

Best practices include using the console variable r.Nanite.Visualize.OverdrawScale to modify this value rather than changing GNaniteVisualizeOverdrawScale directly in code, ensuring consistent behavior across the engine.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteVisualize.cpp:40

Scope: file

Source code excerpt:

int32 GNaniteVisualizeOverdrawScale = 15; // % of contribution per pixel evaluation (up to 100%)
FAutoConsoleVariableRef CVarNaniteVisualizeOverdrawScale(
	TEXT("r.Nanite.Visualize.OverdrawScale"),
	GNaniteVisualizeOverdrawScale,
	TEXT("")
);

int32 GNaniteVisualizeComplexityScale = 80; // % of contribution per material evaluation (up to 100%)
FAutoConsoleVariableRef CVarNaniteVisualizeComplexityScale(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteVisualize.cpp:38

Scope: file

Source code excerpt:

);

int32 GNaniteVisualizeOverdrawScale = 15; // % of contribution per pixel evaluation (up to 100%)
FAutoConsoleVariableRef CVarNaniteVisualizeOverdrawScale(
	TEXT("r.Nanite.Visualize.OverdrawScale"),
	GNaniteVisualizeOverdrawScale,
	TEXT("")
);

int32 GNaniteVisualizeComplexityScale = 80; // % of contribution per material evaluation (up to 100%)
FAutoConsoleVariableRef CVarNaniteVisualizeComplexityScale(
	TEXT("r.Nanite.Visualize.ComplexityScale"),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteVisualize.cpp:134

Scope (from outer to inner):

file
function     static FIntVector4 GetVisualizeScales

Source code excerpt:

	if (ModeID != INDEX_NONE)
	{
		return FIntVector4(GNaniteVisualizeOverdrawScale, GNaniteVisualizeComplexityScale, int32(ShadingExportCount), 0 /* Unused */);
	}

	return FIntVector4(INDEX_NONE, 0, 0, 0);
}

static bool VisualizationRequiresHiZDecode(int32 ModeID)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:172

Scope: file

Source code excerpt:

#endif

extern int32 GNaniteVisualizeOverdrawScale;

// The tile size in pixels for VSM projection with tile list.
// Is also used as the workgroup size for the CS without tile list.
static constexpr int32 VSMProjectionWorkTileSize = 8;

bool IsVSMTranslucentHighQualityEnabled()

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapProjection.cpp:398

Scope (from outer to inner):

file
function     static void RenderVirtualShadowMapProjectionCommon

Source code excerpt:

		PassParameters->VisualizeModeId = VisualizationData.GetActiveModeID();
		PassParameters->VisualizeVirtualShadowMapId = VirtualShadowMapArray.VisualizeLight[ViewIndex].GetVirtualShadowMapId();
		PassParameters->VisualizeNaniteOverdrawScale = GNaniteVisualizeOverdrawScale;
		PassParameters->PhysicalPageMetaData = GraphBuilder.CreateSRV( VirtualShadowMapArray.PhysicalPageMetaDataRDG );
		PassParameters->OutVisualize = GraphBuilder.CreateUAV( VirtualShadowMapArray.DebugVisualizationOutput[ViewIndex] );
	}
#endif

	// If the requested samples per ray matches one of our static permutations, pick that one