r.Substrate.DBufferPass

r.Substrate.DBufferPass

#Overview

name: r.Substrate.DBufferPass

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.Substrate.DBufferPass is to control the application of the DBuffer pass after the base pass in the Substrate rendering system of Unreal Engine 5. It is primarily used for the rendering system, specifically for the Substrate material system.

This setting variable is mainly relied upon by the Substrate rendering subsystem within Unreal Engine 5. It’s referenced in the RenderCore and Engine modules, indicating its importance in the rendering pipeline.

The value of this variable is set through a console variable (CVar) declaration in the RenderCore module. It’s initialized with a default value of 0 and is marked as read-only and render thread safe.

This variable interacts with other Substrate-related settings, such as the normal quality setting and the overall Substrate system enablement. It’s also related to the DBuffer (Decal Buffer) system in Unreal Engine.

Developers must be aware that:

  1. This setting is read-only and changes require shader recompilation.
  2. It’s platform-dependent, with different behaviors on console platforms versus PC.
  3. It’s tied to the normal quality settings and DBuffer support.

Best practices when using this variable include:

  1. Avoid changing it at runtime due to its read-only nature and shader recompilation requirement.
  2. Consider platform-specific implications when enabling or disabling this feature.
  3. Ensure that the Substrate system is enabled and DBuffers are in use before relying on this setting.
  4. Be aware of its interaction with normal quality settings, especially on different platforms.
  5. Use it in conjunction with other Substrate visualization tools for debugging and optimization.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarSubstrateDBufferPass(
	TEXT("r.Substrate.DBufferPass"),
	0,
	TEXT("Apply DBuffer after the base-pass as a separate pass. Read only because when this is changed, it will require the recompilation of all shaders."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

// Transition render settings that will disappear when Substrate gets enabled
static TAutoConsoleVariable<int32> CVarMaterialRoughDiffuse(

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

Scope (from outer to inner):

file
function     void FSubstrateVisualizationData::Initialize

Source code excerpt:

			true,
			false, // Disable for now, as it is not important, and is mainly used for debugging
			LOCTEXT("IsSubstrateBufferPassEnabled", "Substrate tiled DBuffer pass (r.Substrate.DBufferPass and r.Substrate.DBufferPass.DedicatedTiles) is disabled"));

		AddVisualizationMode(
			AllModeMap,
			TEXT("OpaqueRoughRefractionClassification"),
			LOCTEXT("OpaqueRoughRefractionClassification", "Opaque Rough Refraction Classification"),
			LOCTEXT("OpaqueRoughRefractionClassificationDesc", "Visualizes Substrate Opaque Rough Refraction Classification"),

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

Scope (from outer to inner):

file
namespace    Substrate
function     bool IsDBufferPassEnabled

Source code excerpt:

		// That is because in high quality normals requires a uint2 UAV which is only supported on some graphic cards on PC 
		// and this is an unknown when compiling shaders at this stage.
		// !!! If this is changed, please update all sites reading r.Substrate.DBufferPass !!!
		const uint32 NormalQuality = GetNormalQuality();
		const bool bDBufferPassSupported = NormalQuality == 0 || (NormalQuality > 0 && IsConsolePlatform(InPlatform));
		
		static FShaderPlatformCachedIniValue<int32> CVarSubstrateDBufferPassPlatform(TEXT("r.Substrate.DBufferPass"));
		return IsSubstrateEnabled() && IsUsingDBuffers(InPlatform) && bDBufferPassSupported && CVarSubstrateDBufferPassPlatform.Get(InPlatform) > 0;
	}

	bool IsOpaqueRoughRefractionEnabled()
	{
		return IsSubstrateEnabled() && CVarSubstrateOpaqueMaterialRoughRefraction.GetValueOnAnyThread() > 0;