r.ClearGBufferDBeforeBasePass
r.ClearGBufferDBeforeBasePass
#Overview
name: r.ClearGBufferDBeforeBasePass
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to clear GBuffer D before basepass
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ClearGBufferDBeforeBasePass is to control whether the GBuffer D should be cleared before the base pass rendering in Unreal Engine’s deferred rendering pipeline.
This setting variable is primarily used in the rendering system, specifically in the base pass rendering stage of the deferred shading pipeline. It is referenced in the Renderer module of Unreal Engine.
The value of this variable is set through a console variable (CVar) named CVarClearGBufferDBeforeBasePass. It is initialized with a default value of 1, meaning the GBuffer D is cleared by default before the base pass.
The associated variable CVarClearGBufferDBeforeBasePass interacts directly with r.ClearGBufferDBeforeBasePass. They share the same value and purpose.
Developers must be aware that this variable affects the rendering performance and visual output. Clearing the GBuffer D before the base pass ensures a clean slate for rendering but may have performance implications.
Best practices when using this variable include:
- Consider the performance impact of clearing the GBuffer D before each base pass.
- Test the visual output with and without clearing to ensure desired results.
- Use it in conjunction with other rendering settings for optimal performance and visual quality.
Regarding the associated variable CVarClearGBufferDBeforeBasePass:
The purpose of CVarClearGBufferDBeforeBasePass is to provide programmatic access to the r.ClearGBufferDBeforeBasePass setting within the C++ code of the Unreal Engine.
This variable is used in the Renderer module, specifically in the base pass rendering logic.
The value of CVarClearGBufferDBeforeBasePass is set when it’s declared as a TAutoConsoleVariable, with an initial value of 1.
It interacts directly with the r.ClearGBufferDBeforeBasePass console variable, serving as its C++ representation.
Developers should be aware that changes to CVarClearGBufferDBeforeBasePass will affect the behavior of the GBuffer D clearing before the base pass.
Best practices for using CVarClearGBufferDBeforeBasePass include:
- Access its value using GetValueOnRenderThread() when in render thread code.
- Consider the implications of changing this value at runtime on rendering performance and quality.
- Use it in conditional statements to alter rendering behavior based on whether GBuffer D should be cleared.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:89
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarClearGBufferDBeforeBasePass(
TEXT("r.ClearGBufferDBeforeBasePass"),
1,
TEXT("Whether to clear GBuffer D before basepass"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarPSOPrecacheLightMapPolicyMode(
TEXT("r.PSOPrecache.LightMapPolicyMode"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarClearGBufferDBeforeBasePass
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:88
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarClearGBufferDBeforeBasePass(
TEXT("r.ClearGBufferDBeforeBasePass"),
1,
TEXT("Whether to clear GBuffer D before basepass"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarPSOPrecacheLightMapPolicyMode(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:1091
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderBasePass
Source code excerpt:
const FGBufferBindings& GBufferBindings = SceneTextures.Config.GBufferBindings[GBL_Default];
if (!CVarClearGBufferDBeforeBasePass.GetValueOnRenderThread() && GBufferBindings.GBufferD.Index > 0 && GBufferBindings.GBufferD.Index < (int32)BasePassTextureCount)
{
PassParameters->RenderTargets[GBufferBindings.GBufferD.Index].SetLoadAction(ERenderTargetLoadAction::ENoAction);
}
GraphBuilder.AddPass(RDG_EVENT_NAME("GBufferClear"), PassParameters, ERDGPassFlags::Raster,
[PassParameters, ColorLoadAction, SceneColorClearValue](FRHICommandList& RHICmdList)