r.DOF.Scatter.NeighborCompareMaxColor

r.DOF.Scatter.NeighborCompareMaxColor

#Overview

name: r.DOF.Scatter.NeighborCompareMaxColor

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.NeighborCompareMaxColor is to control the linear color clamping upper bound in the Depth of Field (DOF) scattering process. It is used in the rendering system, specifically for the Diaphragm Depth of Field effect.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, particularly in the post-processing subsystem for Depth of Field effects. It’s referenced in the DiaphragmDOF.cpp file, which handles the implementation of the Diaphragm DOF effect.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 10, but can be changed at runtime through console commands or programmatically.

The associated variable CVarScatterNeighborCompareMaxColor directly interacts with r.DOF.Scatter.NeighborCompareMaxColor. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects the comparison of pixel colors and their neighbors during the DOF scattering process. Setting the value too low may result in insufficient scattering, while setting it too high may cause unnecessary scattering in highlight areas.

Best practices when using this variable include:

  1. Start with the default value of 10 and adjust as needed.
  2. Test the DOF effect with various scenes, particularly those with bright highlights, to find the optimal value.
  3. Be mindful of performance impacts when adjusting this value, as it affects the DOF calculation process.

Regarding the associated variable CVarScatterNeighborCompareMaxColor:

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<float> CVarScatterNeighborCompareMaxColor(
	TEXT("r.DOF.Scatter.NeighborCompareMaxColor"),
	10,
	TEXT("Controles the linear color clamping upperbound applied before color of pixel and neighbors are compared.")
	TEXT(" To low, and you may not scatter enough; to high you may scatter unnecessarily too much in highlights")
	TEXT(" (Default: 10)."),
	ECVF_RenderThreadSafe);

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

TAutoConsoleVariable<float> CVarScatterNeighborCompareMaxColor(
	TEXT("r.DOF.Scatter.NeighborCompareMaxColor"),
	10,
	TEXT("Controles the linear color clamping upperbound applied before color of pixel and neighbors are compared.")
	TEXT(" To low, and you may not scatter enough; to high you may scatter unnecessarily too much in highlights")
	TEXT(" (Default: 10)."),
	ECVF_RenderThreadSafe);

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

Scope (from outer to inner):

file
function     bool DiaphragmDOF::AddPasses

Source code excerpt:

			PassParameters->PreProcessingToProcessingCocRadiusFactor = GatheringCocRadiusBasis / EncodedCocRadiusBasis;
			PassParameters->MinScatteringCocRadius = MinScatteringCocRadius;
			PassParameters->NeighborCompareMaxColor = CVarScatterNeighborCompareMaxColor.GetValueOnRenderThread();
			PassParameters->CocSqueeze = CocModel.Squeeze;
			
			PassParameters->EyeAdaptationBuffer = GraphBuilder.CreateSRV(GetEyeAdaptationBuffer(GraphBuilder, View));
			PassParameters->CommonParameters = CommonParameters;

			PassParameters->GatherInputSize = FVector4f(SrcSize.X, SrcSize.Y, 1.0f / SrcSize.X, 1.0f / SrcSize.Y);