r.DepthOfFieldQuality

r.DepthOfFieldQuality

#Overview

name: r.DepthOfFieldQuality

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

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.DepthOfFieldQuality is to adjust the quality of the Depth of Field (DOF) effect in Unreal Engine 5’s rendering system. This setting variable allows developers to control the trade-off between visual quality and performance for the DOF effect.

This setting variable is primarily used by the rendering system, specifically in the post-processing pipeline. Based on the callsites, it’s clear that the variable is used in the core engine (ConsoleManager.cpp), the main engine module (SceneView.cpp), and the renderer module (DiaphragmDOF.cpp and DiaphragmDOFUtils.cpp).

The value of this variable is set through the console variable system, as evidenced by its declaration using TAutoConsoleVariable. It can be changed at runtime through console commands or programmatically.

Other variables that interact with r.DepthOfFieldQuality include FinalPostProcessSettings.DepthOfFieldScale and View.FinalPostProcessSettings.DepthOfFieldFstop. The DOF effect is also influenced by the DepthOfField engine show flag.

Developers must be aware that this variable significantly impacts both visual quality and performance. Higher quality settings can be substantially slower, with the highest setting (3) intended for non-realtime cutscenes.

Best practices when using this variable include:

  1. Use the default value (2) for most real-time scenarios, as it provides a good balance between quality and performance.
  2. Consider lowering the value to 1 for performance-critical situations or on lower-end hardware.
  3. Use the highest setting (3) only for non-realtime rendering, such as cutscenes or cinematics.
  4. Be aware that setting the value to 0 will disable the Depth of Field effect entirely.
  5. Test the impact of different quality levels on your specific scenes to find the optimal balance between visual quality and performance.

#Setting Variables

#References In INI files

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

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

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

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

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

Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:91, section: [PostProcessQuality@0]

Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:101, section: [PostProcessQuality@1]

Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:111, section: [PostProcessQuality@2]

Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:121, section: [PostProcessQuality@3]

Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:91, section: [PostProcessQuality@0]

Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:101, section: [PostProcessQuality@1]

Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:111, section: [PostProcessQuality@2]

Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:121, section: [PostProcessQuality@3]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:3700

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDepthOfFieldQuality(
	TEXT("r.DepthOfFieldQuality"),
	2,
	TEXT("Allows to adjust the depth of field quality. Currently only fully affects BokehDOF. GaussianDOF is either 0 for off, otherwise on.\n"
		 " 0: Off\n"
		 " 1: Low\n"
		 " 2: high quality (default, adaptive, can be 4x slower)\n"
		 " 3: very high quality, intended for non realtime cutscenes, CircleDOF only (slow)\n"

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:2098

Scope (from outer to inner):

file
function     void FSceneView::EndFinalPostprocessSettings

Source code excerpt:


	{
		static const auto DepthOfFieldQualityCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DepthOfFieldQuality"));

		int Value = DepthOfFieldQualityCVar->GetValueOnGameThread();

		if(Value <= 0)
		{
			FinalPostProcessSettings.DepthOfFieldScale = 0.0f;

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

Scope (from outer to inner):

file
function     DiaphragmDOF::IsEnabled

Source code excerpt:

bool DiaphragmDOF::IsEnabled(const FViewInfo& View)
{
	static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DepthOfFieldQuality"));
	check(CVar);

	const bool bDepthOfFieldRequestedByCVar = CVar->GetValueOnAnyThread() > 0;

	return
		DiaphragmDOF::IsSupported(View.GetShaderPlatform()) &&

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/DiaphragmDOFUtils.cpp:48

Scope (from outer to inner):

file
function     FVector4f DiaphragmDOF::CircleDofHalfCoc

Source code excerpt:

FVector4f DiaphragmDOF::CircleDofHalfCoc(const FViewInfo& View)
{
	static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DepthOfFieldQuality"));
	bool bDepthOfField = View.Family->EngineShowFlags.DepthOfField && CVar->GetValueOnRenderThread() > 0 && View.FinalPostProcessSettings.DepthOfFieldFstop > 0 && View.FinalPostProcessSettings.DepthOfFieldFocalDistance > 0;

	FVector4f Ret(0, 1, 0, 0);

	if(bDepthOfField)
	{