r.Nanite.AllowComputeMaterials

r.Nanite.AllowComputeMaterials

#Overview

name: r.Nanite.AllowComputeMaterials

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.AllowComputeMaterials is to control whether support for Nanite compute materials is enabled in Unreal Engine 5. This setting is specifically related to the Nanite virtualized geometry system and its interaction with material rendering.

This setting variable is primarily used by the Nanite subsystem within Unreal Engine’s rendering pipeline. It’s referenced in the Engine and RenderCore modules, indicating its importance in the core rendering functionality.

The value of this variable is set through a console variable (CVar) system, allowing it to be changed at runtime. It’s initialized with a default value of 1, meaning Nanite compute materials are enabled by default.

This variable interacts with other Nanite-related settings, such as r.Nanite.AllowLegacyMaterials and r.Nanite.AllowTessellation. Together, these variables control different aspects of Nanite’s material rendering capabilities.

Developers should be aware that this setting is marked as read-only and render thread safe. This means it’s designed to be set at startup or through configuration files, rather than changed frequently during runtime.

Best practices when using this variable include:

  1. Only disable it if there are specific performance or compatibility issues with Nanite compute materials.
  2. Consider the implications on material rendering and performance when changing this setting.
  3. Test thoroughly when modifying this setting, as it can have significant impacts on rendering quality and performance.
  4. Use in conjunction with other Nanite settings for optimal configuration of the virtualized geometry system.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Rendering/NaniteResources.cpp:58

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarNaniteAllowComputeMaterials(
	TEXT("r.Nanite.AllowComputeMaterials"),
	1,
	TEXT("Whether to enable support for Nanite compute materials"),
	ECVF_RenderThreadSafe | ECVF_ReadOnly);

static TAutoConsoleVariable<int32> CVarNaniteAllowLegacyMaterials(
	TEXT("r.Nanite.AllowLegacyMaterials"),

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:1282

Scope (from outer to inner):

file
function     bool NaniteComputeMaterialsSupported

Source code excerpt:

bool NaniteComputeMaterialsSupported()
{
	static const auto AllowComputeMaterials = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Nanite.AllowComputeMaterials"));
	static const bool bAllowComputeMaterials = (AllowComputeMaterials && AllowComputeMaterials->GetValueOnAnyThread() != 0);
	return bAllowComputeMaterials;
}

bool NaniteLegacyMaterialsSupported()
{

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/Shader.cpp:2369

Scope (from outer to inner):

file
function     void ShaderMapAppendKeyString

Source code excerpt:

	{
		static const auto CVarAllowTess = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Nanite.AllowTessellation"));
		static const auto CVarAllowCSMat = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Nanite.AllowComputeMaterials"));
		static const auto CVarAllowPSMat = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Nanite.AllowLegacyMaterials"));

		KeyString.Appendf(
			TEXT("_Nanite-Tess%dCSMat%dPSMat%d"),
			CVarAllowTess ? CVarAllowTess->GetInt() : 0,
			CVarAllowCSMat ? CVarAllowCSMat->GetInt() : 0,