r.Substrate.ShadingQuality

r.Substrate.ShadingQuality

#Overview

name: r.Substrate.ShadingQuality

The value of this variable can be defined or overridden in .ini config files. 2 .ini config files referencing this setting variable.

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Substrate.ShadingQuality is to define the shading quality for the Substrate rendering system in Unreal Engine 5. It controls whether the lighting is calculated accurately or approximately.

This setting variable is primarily used by the Substrate rendering system, which is a part of Unreal Engine’s rendering module. Based on the callsites, it’s clear that this variable is used within the RenderCore subsystem.

The value of this variable is set as a console variable (CVar) with a default value of 1. It’s defined as read-only and render thread safe, meaning it can’t be changed at runtime and is safe to access from the render thread.

The associated variable CVarSubstrateShadingQuality interacts directly with r.Substrate.ShadingQuality. They share the same value and purpose. The CVarSubstrateShadingQuality is used to actually retrieve the value in the code.

Developers must be aware that this variable is read-only, meaning it cannot be changed during runtime. It’s also important to note that the variable accepts two values: 1 for accurate lighting and 2 for approximate lighting.

Best practices when using this variable include:

  1. Understanding the performance implications of accurate vs. approximate lighting.
  2. Setting the appropriate value in the project settings or configuration files before runtime.
  3. Being aware that changing this value may require recompilation of shaders.

Regarding the associated variable CVarSubstrateShadingQuality:

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/Android/AndroidEngine.ini:97, section: [/Script/Engine.RendererSettings]

Location: <Workspace>/Engine/Config/IOS/BaseIOSEngine.ini:15, section: [/Script/Engine.RendererSettings]

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarSubstrateShadingQuality(
	TEXT("r.Substrate.ShadingQuality"),
	1,
	TEXT("Define Substrate shading quality (1: accurate lighting, 2: approximate lighting). This variable is read-only."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarSubstrateDBufferPass(
	TEXT("r.Substrate.DBufferPass"),

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

Scope (from outer to inner):

file
namespace    Substrate
function     uint32 GetShadingQuality

Source code excerpt:

	uint32 GetShadingQuality(EShaderPlatform InPlatform)
	{
		static FShaderPlatformCachedIniValue<int32> CVarSubstrateShadingQualityPlatform(TEXT("r.Substrate.ShadingQuality"));
		return CVarSubstrateShadingQualityPlatform.Get(InPlatform);
	}
	
	bool IsDBufferPassEnabled(EShaderPlatform InPlatform)
	{
		// DBuffer pass is only available if high quality normal is disabled, or if we are on a console.

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarSubstrateShadingQuality(
	TEXT("r.Substrate.ShadingQuality"),
	1,
	TEXT("Define Substrate shading quality (1: accurate lighting, 2: approximate lighting). This variable is read-only."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarSubstrateDBufferPass(

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

Scope (from outer to inner):

file
namespace    Substrate
function     uint32 GetShadingQuality

Source code excerpt:

	uint32 GetShadingQuality()
	{
		return CVarSubstrateShadingQuality.GetValueOnAnyThread();
	}

	uint32 GetShadingQuality(EShaderPlatform InPlatform)
	{
		static FShaderPlatformCachedIniValue<int32> CVarSubstrateShadingQualityPlatform(TEXT("r.Substrate.ShadingQuality"));
		return CVarSubstrateShadingQualityPlatform.Get(InPlatform);