r.FogUseDepthBounds
r.FogUseDepthBounds
#Overview
name: r.FogUseDepthBounds
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allows enable depth bounds optimization on fog full screen pass.\n false: disabled\n true: enabled (default)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.FogUseDepthBounds is to enable or disable the depth bounds optimization for the fog full-screen pass in the rendering system of Unreal Engine 5.
This setting variable is primarily used in the rendering subsystem of Unreal Engine 5, specifically in the fog rendering module. It’s referenced in the FogRendering.cpp file, which is part of the Renderer module.
The value of this variable is set through a console variable (CVarFogUseDepthBounds) using the TAutoConsoleVariable template. It’s initialized with a default value of true, meaning the optimization is enabled by default.
The associated variable CVarFogUseDepthBounds directly interacts with r.FogUseDepthBounds. They share the same value and purpose.
Developers must be aware that this variable affects the performance and potentially the visual quality of fog rendering. When enabled, it uses depth bounds testing to optimize the fog full-screen pass, which can improve performance by reducing unnecessary shader executions.
Best practices when using this variable include:
- Keeping it enabled (true) for better performance in most cases.
- Disabling it (false) if any visual artifacts or inconsistencies in fog rendering are observed.
- Testing both enabled and disabled states in various scenes to ensure the optimization doesn’t negatively impact the visual quality of the fog.
Regarding the associated variable CVarFogUseDepthBounds:
The purpose of CVarFogUseDepthBounds is the same as r.FogUseDepthBounds - to control the depth bounds optimization for fog rendering.
It’s used in the Renderer module, specifically in the fog rendering system.
The value is set when the TAutoConsoleVariable is initialized, but can be changed at runtime through console commands.
This variable directly interacts with the GraphicsPSOInit.bDepthBounds property, which is used to set up the depth bound optimization for the graphics pipeline.
Developers should be aware that this variable’s value is accessed on potentially any thread (GetValueOnAnyThread()), so thread safety should be considered when modifying it.
Best practices include using this variable in conjunction with GSupportsDepthBoundsTest to ensure the optimization is only applied on platforms that support it, and considering the impact on fog rendering when volumetric fog or local fog volumes are in use.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/FogRendering.cpp:24
Scope: file
Source code excerpt:
static TAutoConsoleVariable<bool> CVarFogUseDepthBounds(
TEXT("r.FogUseDepthBounds"),
true,
TEXT("Allows enable depth bounds optimization on fog full screen pass.\n")
TEXT(" false: disabled\n")
TEXT(" true: enabled (default)"),
ECVF_RenderThreadSafe);
#Associated Variable and Callsites
This variable is associated with another variable named CVarFogUseDepthBounds
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/FogRendering.cpp:23
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<bool> CVarFogUseDepthBounds(
TEXT("r.FogUseDepthBounds"),
true,
TEXT("Allows enable depth bounds optimization on fog full screen pass.\n")
TEXT(" false: disabled\n")
TEXT(" true: enabled (default)"),
ECVF_RenderThreadSafe);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/FogRendering.cpp:357
Scope: file
Source code excerpt:
// Setup the depth bound optimization if possible on that platform.
GraphicsPSOInit.bDepthBounds = GSupportsDepthBoundsTest && CVarFogUseDepthBounds.GetValueOnAnyThread() && !bSampleFogOnClouds;
if (GraphicsPSOInit.bDepthBounds)
{
float FogStartDistance = GetViewFogCommonStartDistance(View, bShouldRenderVolumetricFog, bFogComposeLocalFogVolumes);
// Here we compute the nearest z value the fog can start
// to skip shader execution on pixels that are closer.