r.SelectiveBasePassOutputs

r.SelectiveBasePassOutputs

#Overview

name: r.SelectiveBasePassOutputs

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.SelectiveBasePassOutputs is to optimize rendering performance by selectively outputting to the GBuffer rendertargets. This setting variable is primarily used in the rendering system of Unreal Engine 5.

Based on the callsites, this setting variable is utilized by the Renderer module and the TargetPlatform module. It’s also referenced in the RenderCore module for platform-specific optimizations.

The value of this variable is set through the URendererSettings class, which is part of the Engine module. It can be configured in the project settings or through the console variable system.

This variable interacts with the GSelectiveBasePassOutputsPlatformMask, which is initialized based on the value of r.SelectiveBasePassOutputs. This mask is used to determine whether selective base pass outputs are enabled for specific shader platforms.

Developers must be aware that changing this setting requires restarting the editor, as indicated by the ConfigRestartRequired=true meta tag in the UPROPERTY declaration. Additionally, changing this variable causes a full shader recompile, which can be time-consuming.

Best practices when using this variable include:

  1. Consider enabling it for performance optimization, especially on platforms where rendering performance is crucial.
  2. Be aware of the potential impact on shader compilation time when changing this setting.
  3. Test thoroughly after enabling or disabling this feature, as it may affect the visual output of your project.
  4. Use it in conjunction with other rendering optimizations for best results.
  5. Keep in mind that this setting affects all shader platforms, so consider its impact on different target platforms for your project.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/RendererSettings.h:810

Scope (from outer to inner):

file
class        class URendererSettings : public UDeveloperSettings

Source code excerpt:


	UPROPERTY(config, EditAnywhere, Category=Optimizations, meta=(
		ConsoleVariable="r.SelectiveBasePassOutputs", DisplayName="Selectively output to the GBuffer rendertargets",
		ToolTip="Enables not exporting to the GBuffer rendertargets that are not relevant. Changing this setting requires restarting the editor.",
		ConfigRestartRequired=true))
	uint32 bSelectiveBasePassOutputs:1;

	UPROPERTY(config, EditAnywhere, Category = Optimizations, meta = (
		DisplayName = "Enable Particle Cutouts by default",

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:38

Scope: file

Source code excerpt:

// Changing this causes a full shader recompile
static TAutoConsoleVariable<int32> CVarSelectiveBasePassOutputs(
	TEXT("r.SelectiveBasePassOutputs"),
	0,
	TEXT("Enables shaders to only export to relevant rendertargets.\n") \
	TEXT(" 0: Export in all rendertargets.\n") \
	TEXT(" 1: Export only into relevant rendertarget.\n"),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformBase.cpp:40

Scope (from outer to inner):

file
function     bool FTargetPlatformBase::UsesSelectiveBasePassOutputs

Source code excerpt:

bool FTargetPlatformBase::UsesSelectiveBasePassOutputs() const
{
	static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SelectiveBasePassOutputs"));
	return CVar ? (CVar->GetInt() != 0) : false;
}

bool FTargetPlatformBase::UsesDistanceFields() const
{
	static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DistanceFields"));

#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformSettingsBase.cpp:29

Scope (from outer to inner):

file
function     bool FTargetPlatformSettingsBase::UsesSelectiveBasePassOutputs

Source code excerpt:

bool FTargetPlatformSettingsBase::UsesSelectiveBasePassOutputs() const
{
	static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SelectiveBasePassOutputs"));
	return CVar ? (CVar->GetInt() != 0) : false;
}

bool FTargetPlatformSettingsBase::UsesDistanceFields() const
{
	static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DistanceFields"));

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

Scope (from outer to inner):

file
function     void RenderUtilsInit

Source code excerpt:

	GDBufferPlatformMask.Init(DBufferVar && DBufferVar->GetInt(), EShaderPlatform::SP_NumPlatforms);

	static IConsoleVariable* SelectiveBasePassOutputsCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SelectiveBasePassOutputs"));
	GSelectiveBasePassOutputsPlatformMask.Init(SelectiveBasePassOutputsCVar && SelectiveBasePassOutputsCVar->GetInt(), EShaderPlatform::SP_NumPlatforms);

	static IConsoleVariable* DistanceFieldsCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DistanceFields")); 
	GDistanceFieldsPlatformMask.Init(DistanceFieldsCVar && DistanceFieldsCVar->GetInt(), EShaderPlatform::SP_NumPlatforms);

	static IConsoleVariable* RayTracingCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing"));