r.Nanite.ShowUnsupportedError

r.Nanite.ShowUnsupportedError

#Overview

name: r.Nanite.ShowUnsupportedError

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.ShowUnsupportedError is to control the display of error messages related to unsupported Nanite features in the rendering system. This setting variable is part of Unreal Engine 5’s Nanite virtualized geometry system.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the scene rendering component. This can be seen from the file path “Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp” where the variable is defined and used.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, but can be changed at runtime through the console or configuration files.

This variable interacts with the Nanite system and the engine’s error reporting mechanism. It’s closely associated with another variable named CVarNaniteShowUnsupportedError, which is actually the implementation of the console variable.

Developers must be aware that this variable has three possible values: 0: Disables the error message 1: Shows an error if Nanite is present in the scene but unsupported, and fallback meshes are not used for rendering (default) 2: Shows an error if Nanite is present in the scene but unsupported, even if fallback meshes are used for rendering

The best practices when using this variable include:

  1. Use it for debugging purposes, especially when implementing or testing Nanite features.
  2. Be aware that it’s only active in non-shipping and non-test builds (#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)).
  3. Consider setting it to 2 during development to catch all potential Nanite issues, even when fallback meshes are used.
  4. Set it to 0 in release builds to avoid unnecessary error messages for end-users.

Regarding the associated variable CVarNaniteShowUnsupportedError:

The purpose of CVarNaniteShowUnsupportedError is to implement the console variable functionality for r.Nanite.ShowUnsupportedError. It’s the actual variable that stores the setting value and provides the interface for the console system to interact with this setting.

This variable is part of the Unreal Engine’s console variable system, which is used throughout the engine for runtime configuration.

The value of this variable is set through the console variable system, either via console commands or configuration files.

It directly interacts with r.Nanite.ShowUnsupportedError, essentially being the backend for that user-facing setting.

Developers should be aware that this is the actual variable being checked in the code (CVarNaniteShowUnsupportedError.GetValueOnRenderThread()), not r.Nanite.ShowUnsupportedError directly.

Best practices for using this variable include:

  1. Use GetValueOnRenderThread() when accessing its value in render thread code.
  2. Remember that changes to this variable will affect the behavior of Nanite error reporting in real-time.
  3. Consider the performance implications of frequently checking this variable’s value in performance-critical code paths.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:423

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarNaniteShowUnsupportedError(
	TEXT("r.Nanite.ShowUnsupportedError"),
	1,
	TEXT("Specify behavior of Nanite unsupported screen error message.\n")
	TEXT(" 0: disabled\n")
	TEXT(" 1: show error if Nanite is present in the scene but unsupported, and fallback meshes are not used for rendering; (default)")
	TEXT(" 2: show error if Nanite is present in the scene but unsupported, even if fallback meshes are used for rendering")
);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:422

Scope: file

Source code excerpt:

#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)

static TAutoConsoleVariable<int32> CVarNaniteShowUnsupportedError(
	TEXT("r.Nanite.ShowUnsupportedError"),
	1,
	TEXT("Specify behavior of Nanite unsupported screen error message.\n")
	TEXT(" 0: disabled\n")
	TEXT(" 1: show error if Nanite is present in the scene but unsupported, and fallback meshes are not used for rendering; (default)")
	TEXT(" 2: show error if Nanite is present in the scene but unsupported, even if fallback meshes are used for rendering")

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:3755

Scope (from outer to inner):

file
function     void FSceneRenderer::OnRenderFinish

Source code excerpt:

		const bool bShowLocalExposureDisabledWarning = ViewFamily.EngineShowFlags.VisualizeLocalExposure && !bLocalExposureEnabledOnAnyView;

		const int32 NaniteShowError = CVarNaniteShowUnsupportedError.GetValueOnRenderThread();
		// 0: disabled
		// 1: show error if Nanite is present in the scene but unsupported, and fallback meshes are not used for rendering
		// 2: show error if Nanite is present in the scene but unsupported, even if fallback meshes are used for rendering

		static const auto NaniteProxyRenderModeVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Nanite.ProxyRenderMode"));
		const int32 NaniteProxyRenderMode = (NaniteProxyRenderModeVar != nullptr) ? (NaniteProxyRenderModeVar->GetInt() != 0) : 0;