r.DepthOfField.NearBlurSizeThreshold
r.DepthOfField.NearBlurSizeThreshold
#Overview
name: r.DepthOfField.NearBlurSizeThreshold
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Sets the minimum near blur size before the effect is forcably disabled. Currently only affects Gaussian DOF.\n (default: 0.01)
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DepthOfField.NearBlurSizeThreshold is to control the minimum near blur size for the Depth of Field (DOF) effect in Unreal Engine’s rendering system. Specifically, it sets a threshold below which the near DOF effect is forcibly disabled to prevent visual artifacts or unnecessary processing.
This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the post-processing pipeline for Depth of Field effects. It’s most relevant to the Gaussian Depth of Field implementation.
The value of this variable is set as a console variable with a default value of 0.01. It can be modified at runtime through the console or programmatically.
The associated variable CVarDepthOfFieldNearBlurSizeThreshold directly interacts with r.DepthOfField.NearBlurSizeThreshold. They share the same value and purpose.
Developers should be aware that this variable specifically affects the near blur of the Depth of Field effect. It’s used as a threshold to determine whether the near DOF effect should be applied or not. If the calculated near blur size is less than this threshold, the effect is disabled for that frame.
Best practices when using this variable include:
- Carefully adjusting the value to balance visual quality and performance.
- Testing the DOF effect with various scene configurations to ensure the threshold is appropriate for your game’s visual style.
- Being aware that very low values might lead to subtle, potentially unwanted DOF effects, while higher values might disable the near DOF more frequently.
Regarding the associated variable CVarDepthOfFieldNearBlurSizeThreshold:
- Its purpose is identical to r.DepthOfField.NearBlurSizeThreshold.
- It’s used in the Renderer module, specifically in the post-processing code for Depth of Field.
- The value is set when the console variable is initialized and can be accessed using GetValueOnRenderThread().
- It’s used in conditional checks to determine if the near DOF effect should be applied.
- Developers should treat it as they would r.DepthOfField.NearBlurSizeThreshold, as they represent the same setting.
When working with this variable, developers should consider its impact on both visual quality and performance, as it can affect when the DOF effect is applied or disabled in a scene.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:83
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
{
TAutoConsoleVariable<float> CVarDepthOfFieldNearBlurSizeThreshold(
TEXT("r.DepthOfField.NearBlurSizeThreshold"),
0.01f,
TEXT("Sets the minimum near blur size before the effect is forcably disabled. Currently only affects Gaussian DOF.\n")
TEXT(" (default: 0.01)"),
ECVF_RenderThreadSafe);
TAutoConsoleVariable<float> CVarDepthOfFieldMaxSize(
#Associated Variable and Callsites
This variable is associated with another variable named CVarDepthOfFieldNearBlurSizeThreshold
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:82
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
namespace
{
TAutoConsoleVariable<float> CVarDepthOfFieldNearBlurSizeThreshold(
TEXT("r.DepthOfField.NearBlurSizeThreshold"),
0.01f,
TEXT("Sets the minimum near blur size before the effect is forcably disabled. Currently only affects Gaussian DOF.\n")
TEXT(" (default: 0.01)"),
ECVF_RenderThreadSafe);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:2088
Scope (from outer to inner):
file
function static bool IsGaussianActive
Source code excerpt:
FarSize = FMath::Min(FarSize, MaxSize);
NearSize = FMath::Min(NearSize, MaxSize);
const float CVarThreshold = CVarDepthOfFieldNearBlurSizeThreshold.GetValueOnRenderThread();
if ((FarSize < 0.01f) && (NearSize < CVarThreshold))
{
return false;
}
return true;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:2416
Scope (from outer to inner):
file
function void AddMobilePostProcessingPasses
Source code excerpt:
NearSize = FMath::Min(NearSize, MaxSize);
const bool bFar = FarSize >= 0.01f;
const bool bNear = NearSize >= CVarDepthOfFieldNearBlurSizeThreshold.GetValueOnRenderThread();
const bool bCombinedNearFarPass = bFar && bNear;
if (bFar || bNear)
{
// AddGaussianDofBlurPass produces a blurred image from setup or potentially from taa result.
auto AddGaussianDofBlurPass = [&GraphBuilder, &View](FScreenPassTexture& DOFSetup, bool bFarPass, float KernelSizePercent)