r.Translucency.AutoBeforeDOF

r.Translucency.AutoBeforeDOF

#Overview

name: r.Translucency.AutoBeforeDOF

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.Translucency.AutoBeforeDOF is to automatically bin translucency that occurs after Depth of Field (DOF) effects before DOF if it’s behind the focus distance. This is an experimental feature in Unreal Engine’s rendering system.

This setting variable is primarily used in the rendering subsystem of Unreal Engine, specifically in the scene rendering module. It’s referenced in the SceneRendering.cpp file, which is a core part of the renderer.

The value of this variable is set through a console variable (CVarTranslucencyAutoBeforeDOF) with a default value of 0.5. It can be modified at runtime through console commands or programmatically.

The associated variable CVarTranslucencyAutoBeforeDOF interacts directly with r.Translucency.AutoBeforeDOF. They share the same value and purpose.

Developers should be aware that this feature is experimental, as indicated in the comment. It affects how translucent objects are rendered in relation to the Depth of Field effect, potentially improving visual quality in certain scenarios.

When using this variable, best practices include:

  1. Testing thoroughly, as it may impact performance and visual quality.
  2. Adjusting the value (between 0 and 1) to find the optimal setting for your specific scene.
  3. Being cautious when using in production as it’s marked experimental.

The associated variable CVarTranslucencyAutoBeforeDOF is a TAutoConsoleVariable that controls the same functionality. It’s used to set and retrieve the value of r.Translucency.AutoBeforeDOF. When working with this variable, developers should:

  1. Access it using GetValueOnGameThread() for consistency.
  2. Be aware that changes to this variable will directly affect the rendering pipeline.
  3. Consider performance implications when modifying this value frequently during runtime.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:434

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarTranslucencyAutoBeforeDOF(
	TEXT("r.Translucency.AutoBeforeDOF"), 0.5f,
	TEXT("Automatically bin After DOF translucency before DOF if behind focus distance (Experimental)"),
	ECVF_Default);


static FParallelCommandListSet* GOutstandingParallelCommandListSet = nullptr;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:433

Scope: file

Source code excerpt:

#endif

static TAutoConsoleVariable<float> CVarTranslucencyAutoBeforeDOF(
	TEXT("r.Translucency.AutoBeforeDOF"), 0.5f,
	TEXT("Automatically bin After DOF translucency before DOF if behind focus distance (Experimental)"),
	ECVF_Default);


static FParallelCommandListSet* GOutstandingParallelCommandListSet = nullptr;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:2728

Scope (from outer to inner):

file
function     FSceneRenderer::FSceneRenderer

Source code excerpt:

		}

		if (CVarTranslucencyAutoBeforeDOF.GetValueOnGameThread() >= 0.0f && DiaphragmDOF::IsEnabled(*ViewInfo))
		{
			ViewInfo->AutoBeforeDOFTranslucencyBoundary = ViewInfo->FinalPostProcessSettings.DepthOfFieldFocalDistance / FMath::Clamp(1.0f - CVarTranslucencyAutoBeforeDOF.GetValueOnGameThread(), 0.01f, 1.0f);
		}
	}

	// Catches inconsistency one engine show flags for screen percentage and whether it is supported or not.
	ensureMsgf(!(ViewFamily.EngineShowFlags.ScreenPercentage && !ViewFamily.SupportsScreenPercentage()),
		TEXT("Screen percentage is not supported, but show flag was incorectly set to true."));