r.Nanite.Visualize.ComplexityScale

r.Nanite.Visualize.ComplexityScale

#Overview

name: r.Nanite.Visualize.ComplexityScale

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.Visualize.ComplexityScale is to control the visualization of shader complexity for Nanite-rendered objects in Unreal Engine 5. It specifically sets the scale for the contribution of material evaluations to the overall complexity visualization.

This setting variable is primarily used in the Nanite rendering system, which is part of Unreal Engine 5’s advanced geometry system. It’s utilized within the Renderer module, specifically in the Nanite visualization functionality.

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

The variable interacts directly with its associated C++ variable GNaniteVisualizeComplexityScale. They share the same value, with the console variable providing a way to modify the value at runtime.

Developers should be aware that this variable affects the visual representation of shader complexity for Nanite objects. Changing this value will impact how the complexity is displayed in the engine’s visualization tools, which can be crucial for performance optimization and debugging.

Best practices when using this variable include:

  1. Use it in conjunction with other Nanite visualization tools for a comprehensive understanding of rendering complexity.
  2. Adjust the value when fine-tuning the visualization to match your specific needs or to better highlight areas of concern.
  3. Remember that this is a visualization tool, and changing it doesn’t affect actual rendering performance - it only changes how complexity is displayed.

Regarding the associated variable GNaniteVisualizeComplexityScale:

The purpose of GNaniteVisualizeComplexityScale is to store the actual value used by the engine for Nanite complexity visualization scaling. It’s the C++ counterpart to the console variable r.Nanite.Visualize.ComplexityScale.

This variable is used directly in the Nanite visualization system, specifically in the GetVisualizeScales function, which appears to be responsible for providing scaling values for different visualization modes.

The value of GNaniteVisualizeComplexityScale is set by the console variable system when r.Nanite.Visualize.ComplexityScale is modified.

It interacts primarily with the console variable system and is used in conjunction with other visualization-related variables like GNaniteVisualizeOverdrawScale.

Developers should be aware that modifying this variable directly in C++ code might lead to inconsistencies with the console variable system. It’s generally better to modify the console variable instead.

Best practices for this variable include:

  1. Treat it as read-only in most cases, relying on the console variable system to modify its value.
  2. Use it when implementing custom visualization features that need to respect the user-set complexity scale.
  3. Consider its value when interpreting or processing Nanite visualization data in custom code.

#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:47

Scope: file

Source code excerpt:

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

// Fudge factor chosen by visually comparing Nanite vs non-Nanite cube shader complexity using default material, and choosing value where colors match.
int32 GNaniteVisualizeComplexityOverhead = 7400; // Baseline overhead of Nanite ALU (added to global shader budget)

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

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

// Fudge factor chosen by visually comparing Nanite vs non-Nanite cube shader complexity using default material, and choosing value where colors match.
int32 GNaniteVisualizeComplexityOverhead = 7400; // Baseline overhead of Nanite ALU (added to global shader budget)
FAutoConsoleVariableRef CVarNaniteVisualizeComplexityOverhead(

#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)