ShowFlag.VisualizeDOF

ShowFlag.VisualizeDOF

#Overview

name: ShowFlag.VisualizeDOF

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.VisualizeDOF is to help developers visualize and debug the Depth of Field (DOF) effect in Unreal Engine 5. It’s primarily used for the rendering system, specifically for post-processing effects.

This setting variable is relied upon by the Renderer module of Unreal Engine 5. It’s used in various post-processing related files such as LightShaftRendering.cpp, DiaphragmDOF.cpp, and PostProcessing.cpp.

The value of this variable is set using the SHOWFLAG_FIXED_IN_SHIPPING macro in the ShowFlagsValues.inl file. It’s initialized to 0, meaning it’s disabled by default in shipping builds.

The associated variable VisualizeDOF interacts directly with ShowFlag.VisualizeDOF. They share the same value and are used interchangeably in the code.

Developers must be aware that enabling this flag will visualize the Depth of Field layers, which is useful for debugging but not intended for final renders. When enabled, it may disable other post-processing effects to isolate the DOF visualization.

Best practices when using this variable include:

  1. Use it during development and debugging of DOF effects.
  2. Disable it for final builds or screenshots.
  3. Be aware that it may affect other post-processing effects when enabled.

Regarding the associated variable VisualizeDOF:

The purpose of VisualizeDOF is the same as ShowFlag.VisualizeDOF - to visualize Depth of Field layers for debugging purposes.

It’s used in the same Renderer module and files as ShowFlag.VisualizeDOF.

The value is set in the same way, using the SHOWFLAG_FIXED_IN_SHIPPING macro.

It interacts directly with ShowFlag.VisualizeDOF, sharing the same value.

Developers should treat VisualizeDOF the same way as ShowFlag.VisualizeDOF, using it for debugging and disabling it for final builds.

The best practices for VisualizeDOF are the same as those for ShowFlag.VisualizeDOF.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:101

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(0, TestImage, SFG_Developer, NSLOCTEXT("UnrealEd", "TestImageSF", "Test Image"))
/** Helper to tweak depth of field */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeDOF, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeDOFSF", "Depth of Field Layers"))
/** Show Vertex Colors */
SHOWFLAG_FIXED_IN_SHIPPING(0, VertexColors, SFG_Advanced, NSLOCTEXT("UnrealEd", "VertexColorsSF", "Vertex Colors"))
/** Show Physical Material Masks */
SHOWFLAG_FIXED_IN_SHIPPING(0, PhysicalMaterialMasks, SFG_Advanced, NSLOCTEXT("UnrealEd", "PhysicalMaterialMasksSF", "Physical Material Masks"))
/** Render Post process (screen space) distortion/refraction */
SHOWFLAG_FIXED_IN_SHIPPING(1, Refraction, SFG_Developer, NSLOCTEXT("UnrealEd", "RefractionSF", "Refraction"))

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:101

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(0, TestImage, SFG_Developer, NSLOCTEXT("UnrealEd", "TestImageSF", "Test Image"))
/** Helper to tweak depth of field */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeDOF, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeDOFSF", "Depth of Field Layers"))
/** Show Vertex Colors */
SHOWFLAG_FIXED_IN_SHIPPING(0, VertexColors, SFG_Advanced, NSLOCTEXT("UnrealEd", "VertexColorsSF", "Vertex Colors"))
/** Show Physical Material Masks */
SHOWFLAG_FIXED_IN_SHIPPING(0, PhysicalMaterialMasks, SFG_Advanced, NSLOCTEXT("UnrealEd", "PhysicalMaterialMasksSF", "Physical Material Masks"))
/** Render Post process (screen space) distortion/refraction */
SHOWFLAG_FIXED_IN_SHIPPING(1, Refraction, SFG_Developer, NSLOCTEXT("UnrealEd", "RefractionSF", "Refraction"))

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightShaftRendering.cpp:111

Scope (from outer to inner):

file
function     bool ShouldRenderLightShafts

Source code excerpt:

		&& ViewFamily.EngineShowFlags.Lighting
		&& !ViewFamily.UseDebugViewPS()
		&& !ViewFamily.EngineShowFlags.VisualizeDOF
		&& !ViewFamily.EngineShowFlags.VisualizeBuffer
		&& !ViewFamily.EngineShowFlags.VisualizeHDR
		&& !ViewFamily.EngineShowFlags.VisualizeMotionBlur;
}

bool ShouldRenderLightShaftsForLight(const FViewInfo& View, const FLightSceneProxy& LightSceneProxy)

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

Scope (from outer to inner):

file
function     bool DiaphragmDOF::AddPasses

Source code excerpt:

	FRDGTextureRef& OutputColor)
{
	if (View.Family->EngineShowFlags.VisualizeDOF)
	{
		// no need for this pass
		OutputColor = InputSceneColor;
		return false;
	}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:584

Scope (from outer to inner):

file
function     void AddPostProcessingPasses

Source code excerpt:

		const bool bHasViewState = View.ViewState != nullptr;
		const bool bDepthOfFieldEnabled = DiaphragmDOF::IsEnabled(View);
		const bool bVisualizeDepthOfField = bDepthOfFieldEnabled && EngineShowFlags.VisualizeDOF;
		const bool bVisualizeMotionBlur = IsVisualizeMotionBlurEnabled(View);
		const bool bVisualizeTSR = IsVisualizeTSREnabled(View);

		const EAutoExposureMethod AutoExposureMethod = GetAutoExposureMethod(View);
		const EAntiAliasingMethod AntiAliasingMethod = !bVisualizeDepthOfField ? View.AntiAliasingMethod : AAM_None;
		const EDownsampleQuality DownsampleQuality = GetDownsampleQuality(CVarDownsampleQuality);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:2204

Scope (from outer to inner):

file
function     void AddMobilePostProcessingPasses

Source code excerpt:


	// HQ gaussian 
	bool bUseDof = GetMobileDepthOfFieldScale(View) > 0.0f && View.Family->EngineShowFlags.DepthOfField && !View.Family->EngineShowFlags.VisualizeDOF;
	bool bUseMobileDof = bUseDof && !View.FinalPostProcessSettings.bMobileHQGaussian;

	bool bUseToneMapper = !View.Family->EngineShowFlags.ShaderComplexity && (IsMobileHDR() || IsMobileColorsRGB());

	bool bUseHighResolutionScreenshotMask = IsHighResolutionScreenshotMaskEnabled(View);