r.DOF.Scatter.ForegroundCompositing

r.DOF.Scatter.ForegroundCompositing

#Overview

name: r.DOF.Scatter.ForegroundCompositing

The value of this variable can be defined or overridden in .ini config files. 4 .ini config files referencing this setting variable.

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.ForegroundCompositing is to control the compositing mode of the foreground hybrid scattering in the Depth of Field (DOF) effect. This setting variable is part of the rendering system, specifically the post-processing pipeline for Depth of Field.

This setting variable is used in the Renderer module of Unreal Engine 5, particularly in the DiaphragmDOF (Depth of Field) implementation. It’s defined and used in the file “DiaphragmDOF.cpp” within the Runtime/Renderer/Private/PostProcess directory.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, which corresponds to the additive compositing mode.

This variable interacts closely with another variable named CVarHybridScatterForegroundMode. In fact, they are the same variable, with r.DOF.Scatter.ForegroundCompositing being the console command to set the value, and CVarHybridScatterForegroundMode being the C++ variable that holds and provides access to this value.

Developers should be aware that this variable accepts two possible values: 0: Disabled 1: Additive (default)

When using this variable, developers should consider the following best practices:

  1. Use it in conjunction with other DOF settings for a cohesive look.
  2. Test different values to find the best visual result for your specific scene.
  3. Be aware of performance implications, as different modes may have different computational costs.

Regarding the associated variable CVarHybridScatterForegroundMode:

This is the actual C++ variable that holds the value set by r.DOF.Scatter.ForegroundCompositing. It’s defined as a TAutoConsoleVariable, which means it’s an integer variable that can be modified at runtime through console commands.

The value of CVarHybridScatterForegroundMode is retrieved in the AddPasses function of the DiaphragmDOF class, where it’s used to set the FgdHybridScatteringMode. This indicates that the setting directly influences how the foreground depth of field effect is computed and composited.

When working with CVarHybridScatterForegroundMode, developers should:

  1. Access its value using GetValueOnRenderThread() when in render thread code.
  2. Be aware that changes to this variable will affect the DOF rendering in real-time.
  3. Consider exposing this setting in user interfaces if fine-tuning of DOF is required in your project.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseScalability.ini:434, section: [PostProcessQuality@1]

Location: <Workspace>/Engine/Config/BaseScalability.ini:467, section: [PostProcessQuality@2]

Location: <Workspace>/Engine/Config/BaseScalability.ini:502, section: [PostProcessQuality@3]

Location: <Workspace>/Engine/Config/BaseScalability.ini:540, section: [PostProcessQuality@Cine]

#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:68

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<int32> CVarHybridScatterForegroundMode(
	TEXT("r.DOF.Scatter.ForegroundCompositing"),
	1,
	TEXT("Compositing mode of the foreground hybrid scattering.\n")
	TEXT(" 0: Disabled;\n")
	TEXT(" 1: Additive (default)."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:



TAutoConsoleVariable<int32> CVarHybridScatterForegroundMode(
	TEXT("r.DOF.Scatter.ForegroundCompositing"),
	1,
	TEXT("Compositing mode of the foreground hybrid scattering.\n")
	TEXT(" 0: Disabled;\n")
	TEXT(" 1: Additive (default)."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

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

Scope (from outer to inner):

file
function     bool DiaphragmDOF::AddPasses

Source code excerpt:


	// The mode for hybrid scattering.
	const EHybridScatterMode FgdHybridScatteringMode = EHybridScatterMode(CVarHybridScatterForegroundMode.GetValueOnRenderThread());
	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);