r.DOF.Scatter.MinCocRadius

r.DOF.Scatter.MinCocRadius

#Overview

name: r.DOF.Scatter.MinCocRadius

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.DOF.Scatter.MinCocRadius is to set the minimal Circle of Confusion (CoC) radius required for scattering in the Depth of Field (DOF) effect. This setting is part of the rendering system, specifically the post-processing pipeline for Depth of Field.

This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the DiaphragmDOF (Depth of Field) implementation. It’s referenced in the file “DiaphragmDOF.cpp”, which suggests it’s a part of the post-processing effects for rendering.

The value of this variable is set as a console variable (CVar) with a default value of 3.0f. It can be modified at runtime through the console or configuration files.

This variable interacts with another variable named CVarScatterMinCocRadius, which is the C++ representation of the console variable. They share the same value and purpose.

Developers should be aware that this variable affects the quality and performance of the Depth of Field effect. A higher value will result in less scattering, potentially improving performance but reducing the quality of the bokeh effect for smaller out-of-focus areas.

Best practices when using this variable include:

  1. Adjusting it based on the specific visual requirements of your scene.
  2. Considering performance implications, especially on lower-end hardware.
  3. Testing different values to find the right balance between visual quality and performance.

Regarding the associated variable CVarScatterMinCocRadius:

This is the C++ variable that directly corresponds to the console variable r.DOF.Scatter.MinCocRadius. It’s used within the engine code to access the current value of the setting. The purpose and considerations are the same as for r.DOF.Scatter.MinCocRadius.

It’s defined as a TAutoConsoleVariable, which means it’s automatically registered with the console variable system and can be modified at runtime. The value is retrieved in the rendering code using GetValueOnRenderThread(), ensuring thread-safe access.

Developers should note that while they can access this variable directly in C++ code, it’s generally better to use the console variable interface (r.DOF.Scatter.MinCocRadius) for consistency and to allow for easy runtime modification and config file support.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/DiaphragmDOF.cpp:92

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<float> CVarScatterMinCocRadius(
	TEXT("r.DOF.Scatter.MinCocRadius"),
	3.0f,
	TEXT("Minimal Coc radius required to be scattered (default = 3)."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

TAutoConsoleVariable<float> CVarScatterMaxSpriteRatio(
	TEXT("r.DOF.Scatter.MaxSpriteRatio"),

#Associated Variable and Callsites

This variable is associated with another variable named CVarScatterMinCocRadius. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/DiaphragmDOF.cpp:91

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

TAutoConsoleVariable<float> CVarScatterMinCocRadius(
	TEXT("r.DOF.Scatter.MinCocRadius"),
	3.0f,
	TEXT("Minimal Coc radius required to be scattered (default = 3)."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

TAutoConsoleVariable<float> CVarScatterMaxSpriteRatio(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/DiaphragmDOF.cpp:1398

Scope (from outer to inner):

file
function     bool DiaphragmDOF::AddPasses

Source code excerpt:

	const EHybridScatterMode BgdHybridScatteringMode = EHybridScatterMode(CVarHybridScatterBackgroundMode.GetValueOnRenderThread());
	
	const float MinScatteringCocRadius = FMath::Max(CVarScatterMinCocRadius.GetValueOnRenderThread(), kMinScatteringCocRadius);

	// Whether the platform support gather bokeh simmulation.
	const bool bSupportGatheringBokehSimulation = SupportsBokehSimmulation(ShaderPlatform);

	// Whether should use shade permutation that does lower quality accumulation.
	// TODO: this is becoming a mess.