r.DepthOfField.DepthBlur.ResolutionScale

r.DepthOfField.DepthBlur.ResolutionScale

#Overview

name: r.DepthOfField.DepthBlur.ResolutionScale

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.DepthOfField.DepthBlur.ResolutionScale is to adjust the depth blur radius in the Depth of Field (DOF) effect, specifically for the CircleDOF DepthBlur feature. It’s designed to scale the depth blur based on the screen resolution, particularly for resolutions larger than 1920x1080.

This setting variable is primarily used in the rendering system of Unreal Engine, specifically in the post-processing pipeline for Depth of Field effects. Based on the callsites, it’s utilized in the Engine module, particularly in the SceneView component.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1.0f, which means no adjustment is applied by default.

The associated variable CVarDepthOfFieldDepthBlurResolutionScale interacts directly with r.DepthOfField.DepthBlur.ResolutionScale. They share the same value and purpose.

Developers must be aware that:

  1. This is described as a “temporary hack” in the comments, suggesting it might be replaced or removed in future engine versions.
  2. It only affects resolutions larger than 1920 pixels in width.
  3. The scaling is linear based on how much the width exceeds 1920 pixels.

Best practices when using this variable include:

  1. Use it cautiously, given its “temporary hack” status.
  2. Test the visual impact across various screen resolutions, especially those exceeding 1920 pixels in width.
  3. Consider the performance implications of increasing the depth blur radius on higher resolutions.

Regarding the associated variable CVarDepthOfFieldDepthBlurResolutionScale:

Its purpose is identical to r.DepthOfField.DepthBlur.ResolutionScale, as they share the same value and functionality.

It’s used in the Engine module, specifically in the SceneView component of the rendering system.

The value is set through the console variable system and is initialized to 1.0f by default.

It directly interacts with the DepthOfFieldDepthBlurRadius in the FinalPostProcessSettings.

Developers should be aware that:

  1. This variable is used in runtime calculations to adjust the depth blur radius.
  2. It’s applied in the EndFinalPostprocessSettings function of FSceneView.

Best practices include:

  1. Monitor its impact on performance, especially at higher resolutions.
  2. Use it in conjunction with other Depth of Field settings for optimal visual results.
  3. Be prepared for potential changes or deprecation in future engine versions due to its “temporary hack” status.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarDepthOfFieldDepthBlurResolutionScale(
	TEXT("r.DepthOfField.DepthBlur.ResolutionScale"),
	1.0f,
	TEXT("This scale multiplier only affects the CircleDOF DepthBlur feature. It's a temporary hack.\n")
	TEXT("It lineary scale the DepthBlur by the resolution increase over 1920 (in width), does only affect resolution larger than that.\n")
	TEXT("Actual math: float Factor = max(ViewWidth / 1920 - 1, 0); DepthBlurRadius *= 1 + Factor * (CVar - 1)\n")
	TEXT(" 1: No adjustments (default)\n")
	TEXT(" x: if the resolution is 1920 there is no change, if 2x larger than 1920 it scale the radius by x"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Cheat);

static TAutoConsoleVariable<float> CVarDepthOfFieldDepthBlurResolutionScale(
	TEXT("r.DepthOfField.DepthBlur.ResolutionScale"),
	1.0f,
	TEXT("This scale multiplier only affects the CircleDOF DepthBlur feature. It's a temporary hack.\n")
	TEXT("It lineary scale the DepthBlur by the resolution increase over 1920 (in width), does only affect resolution larger than that.\n")
	TEXT("Actual math: float Factor = max(ViewWidth / 1920 - 1, 0); DepthBlurRadius *= 1 + Factor * (CVar - 1)\n")
	TEXT(" 1: No adjustments (default)\n")

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

Scope (from outer to inner):

file
function     void FSceneView::EndFinalPostprocessSettings

Source code excerpt:

		float& DepthBlurRadius = FinalPostProcessSettings.DepthOfFieldDepthBlurRadius;
		{
			float CVarResScale = FMath::Max(1.0f, CVarDepthOfFieldDepthBlurResolutionScale.GetValueOnGameThread());

			float Factor = FMath::Max(UnscaledViewRect.Width() / 1920.0f - 1.0f, 0.0f);

			DepthBlurRadius *= 1.0f + Factor * (CVarResScale - 1.0f);
		}
		{