r.Substrate.Debug.AdvancedVisualizationShaders

r.Substrate.Debug.AdvancedVisualizationShaders

#Overview

name: r.Substrate.Debug.AdvancedVisualizationShaders

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.Substrate.Debug.AdvancedVisualizationShaders is to enable advanced Substrate material debug visualization shaders in Unreal Engine 5. This setting is primarily used for debugging and visualization purposes within the rendering system, specifically for Substrate materials.

This setting variable is primarily used in the rendering subsystem of Unreal Engine 5. Based on the callsites, it’s referenced in the RenderCore, Engine, and Substrate-related modules.

The value of this variable is set through a console variable (CVarSubstrateDebugAdvancedVisualizationShaders) with an initial value of 0 (disabled). It can be changed at runtime through console commands or configuration files.

The associated variable CVarSubstrateDebugAdvancedVisualizationShaders directly interacts with r.Substrate.Debug.AdvancedVisualizationShaders. They share the same value and purpose.

Developers must be aware that enabling this feature can have performance implications. As shown in the RendererSettings.cpp file, enabling this option triggers a warning message indicating that it will make rendering slower and allocate more memory.

Best practices when using this variable include:

  1. Only enable it when necessary for debugging or visualization purposes.
  2. Avoid checking in code with this feature enabled in production builds.
  3. Consider adding the setting to ConsoleVariables.ini for local debugging instead of changing it in shared code.
  4. Be mindful of the performance impact when enabled.

Regarding the associated variable CVarSubstrateDebugAdvancedVisualizationShaders:

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarSubstrateDebugAdvancedVisualizationShaders(
	TEXT("r.Substrate.Debug.AdvancedVisualizationShaders"),
	0,
	TEXT("Enable advanced Substrate material debug visualization shaders. Base pass shaders can output such advanced data."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

namespace Substrate
{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/RendererSettings.cpp:237

Scope (from outer to inner):

file
function     void URendererSettings::PostEditChangeProperty

Source code excerpt:

			&& SubstrateDebugAdvancedVisualizationShaders)
		{
			if (FMessageDialog::Open(EAppMsgType::YesNo, LOCTEXT("Substrate advanced visualization shaders", "This will make the rendering slower and allocate more memory.\nPlease do not check-in.\nInstead you could add `r.Substrate.Debug.AdvancedVisualizationShaders=1` to your ConsoleVariables.ini.\nAre you sure you want to enable that feature now?")) == EAppReturnType::No)
			{
				SubstrateDebugAdvancedVisualizationShaders = false;
				UpdateDependentPropertyInConfigFile(this, GET_MEMBER_NAME_CHECKED(URendererSettings, SubstrateDebugAdvancedVisualizationShaders));
			}
		}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SubstrateVisualizationData.cpp:96

Scope (from outer to inner):

file
function     void FSubstrateVisualizationData::Initialize

Source code excerpt:

			true,
			Substrate::IsAdvancedVisualizationEnabled(),
			LOCTEXT("IsSubstrateAdvancedDebugShaderEnabled", "Substrate advanced debugging r.Substrate.Debug.AdvancedVisualizationShaders is disabled"));

		AddVisualizationMode(
			AllModeMap,
			TEXT("MaterialClassification"),
			LOCTEXT("MaterialClassification", "Material Classification"),
			LOCTEXT("MaterialClassificationDesc", "Visualizes Substrate material classification"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarSubstrateDebugAdvancedVisualizationShaders(
	TEXT("r.Substrate.Debug.AdvancedVisualizationShaders"),
	0,
	TEXT("Enable advanced Substrate material debug visualization shaders. Base pass shaders can output such advanced data."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

namespace Substrate

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

Scope (from outer to inner):

file
namespace    Substrate
function     bool IsAdvancedVisualizationEnabled

Source code excerpt:

	bool IsAdvancedVisualizationEnabled()
	{
		return CVarSubstrateDebugAdvancedVisualizationShaders.GetValueOnAnyThread() > 0;
	}
}

bool DoesPlatformSupportLumenGI(EShaderPlatform Platform, bool bSkipProjectCheck)
{
	static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Lumen.Supported"));