r.DBuffer
r.DBuffer
#Overview
name: r.DBuffer
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables DBuffer decal material blend modes.\nDBuffer decals are rendered before the base pass, allowing them to affect static lighting and skylighting correctly. \nWhen enabled, a full prepass will be forced which adds CPU / GPU cost. Several texture lookups will be done in the base pass to fetch the decal properties, which adds pixel work.\n 0: off\n 1: on (default)
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DBuffer is to control the use of DBuffer decal material blend modes in Unreal Engine’s rendering system. DBuffer decals are a technique used to render decals before the base pass, allowing them to affect static lighting and skylighting correctly.
This setting variable is primarily used by the rendering system within Unreal Engine. It is referenced in various subsystems and modules, including:
- The core engine (ConsoleManager.cpp)
- The renderer settings (RendererSettings.h)
- The target platform system (TargetPlatformBase.cpp and TargetPlatformSettingsBase.cpp)
- The material system (Material.cpp)
- The render core (RenderUtils.cpp)
The value of this variable is set through the console variable system, as indicated by the TAutoConsoleVariable declaration. It can also be configured through the RendererSettings class, which exposes it as a configurable property.
This variable interacts with other rendering-related variables, particularly those affecting the rendering pipeline and material properties. For example, it’s checked alongside the “r.Mobile.DBuffer” variable when determining if the MaterialDecalResponse property can be edited.
Developers must be aware that enabling DBuffer decals forces a full prepass, which can add CPU and GPU cost to the rendering process. Additionally, it requires several texture lookups in the base pass, increasing pixel work.
Best practices when using this variable include:
- Consider the performance implications of enabling DBuffer decals, especially on lower-end hardware.
- Be aware that changing this setting requires restarting the editor for the changes to take effect.
- Use in conjunction with other decal and rendering settings to achieve the desired visual quality and performance balance.
- Test thoroughly on target platforms, as the behavior may vary between desktop and mobile renderers.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:4050
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDBuffer(
TEXT("r.DBuffer"),
1,
TEXT("Enables DBuffer decal material blend modes.\n"
"DBuffer decals are rendered before the base pass, allowing them to affect static lighting and skylighting correctly. \n"
"When enabled, a full prepass will be forced which adds CPU / GPU cost. Several texture lookups will be done in the base pass to fetch the decal properties, which adds pixel work.\n"
" 0: off\n"
" 1: on (default)"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/RendererSettings.h:787
Scope (from outer to inner):
file
class class URendererSettings : public UDeveloperSettings
Source code excerpt:
UPROPERTY(config, EditAnywhere, Category=MiscLighting, meta=(
ConsoleVariable="r.DBuffer",DisplayName="DBuffer Decals",
ToolTip="Whether to accumulate decal properties to a buffer before the base pass. DBuffer decals correctly affect lightmap and sky lighting, unlike regular deferred decals. DBuffer enabled forces a full prepass. Changing this setting requires restarting the editor.",
ConfigRestartRequired=true))
uint32 bDBuffer:1;
UPROPERTY(config, EditAnywhere, Category=Optimizations, meta=(
ConsoleVariable="r.ClearSceneMethod",DisplayName="Clear Scene",
#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformBase.cpp:23
Scope (from outer to inner):
file
function bool FTargetPlatformBase::UsesDBuffer
Source code excerpt:
bool FTargetPlatformBase::UsesDBuffer() const
{
static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DBuffer"));
return CVar ? (CVar->GetInt() != 0) : false;
}
bool FTargetPlatformBase::UsesBasePassVelocity() const
{
static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.VelocityOutputPass"));
#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformSettingsBase.cpp:12
Scope (from outer to inner):
file
function bool FTargetPlatformSettingsBase::UsesDBuffer
Source code excerpt:
bool FTargetPlatformSettingsBase::UsesDBuffer() const
{
static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DBuffer"));
return CVar ? (CVar->GetInt() != 0) : false;
}
bool FTargetPlatformSettingsBase::UsesBasePassVelocity() const
{
static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.VelocityOutputPass"));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Materials/Material.cpp:4492
Scope (from outer to inner):
file
function bool UMaterial::CanEditChange
Source code excerpt:
if (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(UMaterial, MaterialDecalResponse))
{
static auto* CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DBuffer"));
static auto* CVarMobile = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.DBuffer"));
return MaterialDomain == MD_Surface && (CVar->GetValueOnGameThread() > 0 || CVarMobile->GetValueOnGameThread() > 0);
}
if(MaterialDomain == MD_PostProcess)
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:746
Scope (from outer to inner):
file
function void RenderUtilsInit
Source code excerpt:
GForwardShadingPlatformMask.Init(GUseForwardShading == 1, EShaderPlatform::SP_NumPlatforms);
static IConsoleVariable* DBufferVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DBuffer"));
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"));