r.DiffuseIndirectOffUseDepthBoundsAO
r.DiffuseIndirectOffUseDepthBoundsAO
#Overview
name: r.DiffuseIndirectOffUseDepthBoundsAO
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Use depth bounds when we apply the AO when DiffuseIndirect is disabled.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DiffuseIndirectOffUseDepthBoundsAO is to control the use of depth bounds when applying Ambient Occlusion (AO) in scenarios where Diffuse Indirect lighting is disabled. This setting is part of the rendering system, specifically related to indirect lighting and ambient occlusion calculations.
The Unreal Engine’s rendering system, particularly the deferred shading pipeline, relies on this setting variable. It’s used within the IndirectLightRendering module, which is responsible for handling various aspects of indirect lighting in the engine.
The value of this variable is set through the console variable system (CVarDiffuseIndirectOffUseDepthBoundsAO). It’s initialized with a default value of true, meaning depth bounds are used by default when applying AO with disabled Diffuse Indirect lighting.
This variable interacts closely with other rendering-related variables, particularly those controlling Diffuse Indirect lighting methods and Ambient Occlusion. It’s used in conjunction with the engine’s depth buffer system, especially when an inverted depth buffer is in use.
Developers must be aware that this variable only takes effect when Diffuse Indirect lighting is disabled. Its impact is also dependent on the use of an inverted depth buffer and the presence of an Ambient Occlusion mask.
Best practices when using this variable include:
- Ensure it’s only modified when necessary, as it can affect rendering performance.
- Test thoroughly when changing its value, as it interacts with other rendering systems.
- Consider its impact on different hardware configurations, as depth bound optimizations may have varying effects.
Regarding the associated variable CVarDiffuseIndirectOffUseDepthBoundsAO:
The purpose of CVarDiffuseIndirectOffUseDepthBoundsAO is to provide programmatic access to the r.DiffuseIndirectOffUseDepthBoundsAO setting within the C++ code of the engine.
This variable is used directly in the rendering pipeline, specifically in the FDeferredShadingSceneRenderer::RenderDiffuseIndirectAndAmbientOcclusion function. It’s queried to determine whether to use depth bounds optimization when compositing Ambient Occlusion.
The value of this variable is set through the console variable system, mirroring the r.DiffuseIndirectOffUseDepthBoundsAO setting.
It interacts with other rendering variables and systems, including those controlling Diffuse Indirect lighting methods, depth buffer configuration, and Ambient Occlusion masks.
Developers should be aware that this variable is accessed on the render thread, which means changes to it will affect rendering in real-time.
Best practices for using this variable include:
- Access it using the GetValueOnRenderThread() method to ensure thread-safe operations.
- Consider its impact on the entire rendering pipeline when modifying its value.
- Use it in conjunction with other relevant rendering settings for optimal performance and visual quality.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:90
Scope: file
Source code excerpt:
static TAutoConsoleVariable<bool> CVarDiffuseIndirectOffUseDepthBoundsAO(
TEXT("r.DiffuseIndirectOffUseDepthBoundsAO"), true,
TEXT("Use depth bounds when we apply the AO when DiffuseIndirect is disabled."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<bool> CVarDiffuseIndirectForceCopyPass(
TEXT("r.DiffuseIndirectForceCopyPass"), false,
TEXT("Forces use of copy pass instead of dual source blend. (for debugging)"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarDiffuseIndirectOffUseDepthBoundsAO
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:89
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<bool> CVarDiffuseIndirectOffUseDepthBoundsAO(
TEXT("r.DiffuseIndirectOffUseDepthBoundsAO"), true,
TEXT("Use depth bounds when we apply the AO when DiffuseIndirect is disabled."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<bool> CVarDiffuseIndirectForceCopyPass(
TEXT("r.DiffuseIndirectForceCopyPass"), false,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:1439
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderDiffuseIndirectAndAmbientOcclusion
lambda-function
Source code excerpt:
// only use depth bound optimization when diffuse indirect is disable
bool bUseDepthBounds = CVarDiffuseIndirectOffUseDepthBoundsAO.GetValueOnRenderThread() &&
bool(ERHIZBuffer::IsInverted) && // Inverted depth buffer is assumed when setting depth bounds test for AO.
!PermutationVector.Get<FDiffuseIndirectCompositePS::FUpscaleDiffuseIndirectDim>() &&
AmbientOcclusionMask &&
ViewPipelineState.DiffuseIndirectMethod == EDiffuseIndirectMethod::Disabled;
if (bUseDepthBounds)