ShowFlag.CompositeEditorPrimitives

ShowFlag.CompositeEditorPrimitives

#Overview

name: ShowFlag.CompositeEditorPrimitives

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

It is referenced in 14 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.CompositeEditorPrimitives is to control the rendering of editor-specific visual elements, such as gizmos and other foreground editor widgets, in the Unreal Engine editor viewport.

This setting variable is primarily used in the rendering system, specifically in the editor’s viewport rendering pipeline. It affects how editor-specific visual elements are composited with the scene.

The Unreal Engine subsystems that rely on this variable include:

  1. The Renderer module
  2. The UnrealEd module
  3. The LevelEditor module
  4. The ComponentVisualizers module

The value of this variable is typically set in the editor’s viewport settings or through the engine show flags system. It can be toggled on or off depending on the desired visualization in the editor.

This variable interacts with other rendering-related variables, such as EngineShowFlags and other show flags. It also has an associated variable called CompositeEditorPrimitives, which shares the same value and is used interchangeably in the code.

Developers should be aware that:

  1. This flag is only relevant in the editor and is fixed to 0 (disabled) in shipping builds.
  2. When enabled, it causes editor primitives to be rendered in a separate pass and composited after post-processing.
  3. It affects the rendering of various editor tools and visualizers, including component visualizers and level viewport elements.

Best practices when using this variable:

  1. Use it to control the visibility of editor-specific elements in custom editor viewports or tools.
  2. Be mindful of its performance impact, as it introduces an additional rendering pass when enabled.
  3. Consider disabling it when capturing final screenshots or videos of the scene without editor overlays.

Regarding the associated variable CompositeEditorPrimitives: The purpose of CompositeEditorPrimitives is the same as ShowFlag.CompositeEditorPrimitives. It is used interchangeably in the code to control the rendering of editor-specific visual elements. The variable is referenced in various parts of the engine, including the renderer, editor viewport clients, and component visualizers. Developers should treat it the same way as ShowFlag.CompositeEditorPrimitives, following the same best practices and considerations mentioned above.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(MotionBlur, SFG_PostProcess, NSLOCTEXT("UnrealEd", "MotionBlurSF", "Motion Blur"))
/** Whether to render the editor gizmos and other foreground editor widgets off screen and apply them after post process, only needed for the editor */
SHOWFLAG_FIXED_IN_SHIPPING(0, CompositeEditorPrimitives, SFG_Developer, NSLOCTEXT("UnrealEd", "CompositeEditorPrimitivesSF", "Composite Editor Primitives"))
/** When CompositeEditorPrimitives is set, determines whether occluded portions are drawn opaquely on top, or dithered when they are occluded */
SHOWFLAG_FIXED_IN_SHIPPING(0, OpaqueCompositeEditorPrimitives, SFG_Developer, NSLOCTEXT("UnrealEd", "OpaqueCompositeEditorPrimitives", "Make Composite Editor Primitives Opaque"))
/** Shows a test image that allows to tweak the monitor colors, borders and allows to judge image and temporal aliasing  */
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"))

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/ComponentVisualizers/Private/LocalFogVolumeComponentVisualizer.cpp:9

Scope (from outer to inner):

file
function     void FLocalFogVolumeComponentVisualizer::DrawVisualization

Source code excerpt:

void FLocalFogVolumeComponentVisualizer::DrawVisualization( const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI )
{
	if(View->Family->EngineShowFlags.CompositeEditorPrimitives)
	{
		const ULocalFogVolumeComponent* LocalFogVolume = Cast<const ULocalFogVolumeComponent>(Component);
		if(LocalFogVolume != NULL)
		{
			FTransform LocalFogVolumeTransform = LocalFogVolume->GetComponentTransform();

#Loc: <Workspace>/Engine/Source/Editor/LevelEditor/Private/SLevelViewport.cpp:3873

Scope (from outer to inner):

file
function     void SLevelViewport::UpdateActorPreviewViewports

Source code excerpt:

			CurActorPreview.LevelViewportClient->bDrawVertices = LevelViewportClient->bDrawVertices;
			CurActorPreview.LevelViewportClient->EngineShowFlags.SetSelectionOutline(LevelViewportClient->EngineShowFlags.SelectionOutline);
			CurActorPreview.LevelViewportClient->EngineShowFlags.SetCompositeEditorPrimitives(LevelViewportClient->EngineShowFlags.CompositeEditorPrimitives);
		}
	}
}

void SLevelViewport::OnPreviewSelectedCamerasChange()
{

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:6347

Scope (from outer to inner):

file
function     void FEditorViewportClient::SetGameView

Source code excerpt:

{
	// backup this state as we want to preserve it
	bool bCompositeEditorPrimitives = EngineShowFlags.CompositeEditorPrimitives;

	// defaults
	FEngineShowFlags GameFlags(ESFIM_Game);
	FEngineShowFlags EditorFlags(ESFIM_Editor);
	{
		// likely we can take the existing state

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:6403

Scope (from outer to inner):

file
function     void FEditorViewportClient::SetVREditView

Source code excerpt:

{
	// backup this state as we want to preserve it
	bool bCompositeEditorPrimitives = EngineShowFlags.CompositeEditorPrimitives;

	// defaults
	FEngineShowFlags VREditFlags(ESFIM_VREditing);
	FEngineShowFlags EditorFlags(ESFIM_Editor);
	{
		// likely we can take the existing state

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

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(MotionBlur, SFG_PostProcess, NSLOCTEXT("UnrealEd", "MotionBlurSF", "Motion Blur"))
/** Whether to render the editor gizmos and other foreground editor widgets off screen and apply them after post process, only needed for the editor */
SHOWFLAG_FIXED_IN_SHIPPING(0, CompositeEditorPrimitives, SFG_Developer, NSLOCTEXT("UnrealEd", "CompositeEditorPrimitivesSF", "Composite Editor Primitives"))
/** When CompositeEditorPrimitives is set, determines whether occluded portions are drawn opaquely on top, or dithered when they are occluded */
SHOWFLAG_FIXED_IN_SHIPPING(0, OpaqueCompositeEditorPrimitives, SFG_Developer, NSLOCTEXT("UnrealEd", "OpaqueCompositeEditorPrimitives", "Make Composite Editor Primitives Opaque"))
/** Shows a test image that allows to tweak the monitor colors, borders and allows to judge image and temporal aliasing  */
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 */

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:1226

Scope (from outer to inner):

file
lambda-function

Source code excerpt:

		View.SimpleElementCollector.DrawBatchedElements(RHICmdList, DrawRenderState, View, EBlendModeFilter::OpaqueAndMasked, DepthPriorityGroup);

		if (!View.Family->EngineShowFlags.CompositeEditorPrimitives)
		{
			DrawDynamicMeshPass(View, RHICmdList,
				[&View, &DrawRenderState](FDynamicPassMeshDrawListContext* DynamicMeshPassContext)
			{
				FEditorPrimitivesBasePassMeshProcessor PassMeshProcessor(
					View.Family->Scene->GetRenderScene(),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:1280

Scope: file

Source code excerpt:

	bool bHasPrimitives = View.SimpleElementCollector.HasPrimitives(DepthPriorityGroup);

	if (!View.Family->EngineShowFlags.CompositeEditorPrimitives)
	{
		const TIndirectArray<FMeshBatch, SceneRenderingAllocator>& ViewMeshElementList = (DepthPriorityGroup == SDPG_Foreground ? View.TopViewMeshElements : View.ViewMeshElements);
		bHasPrimitives |= ViewMeshElementList.Num() > 0;

		const FBatchedElements& BatchedViewElements = DepthPriorityGroup == SDPG_World ? View.BatchedViewElements : View.TopBatchedViewElements;
		bHasPrimitives |= BatchedViewElements.HasPrimsToDraw();

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DepthRendering.cpp:426

Scope (from outer to inner):

file
function     static void RenderPrePassEditorPrimitives
lambda-function

Source code excerpt:

		View.SimpleElementCollector.DrawBatchedElements(RHICmdList, DrawRenderState, View, EBlendModeFilter::OpaqueAndMasked, SDPG_Foreground);

		if (!View.Family->EngineShowFlags.CompositeEditorPrimitives)
		{
			DrawDynamicMeshPass(View, RHICmdList, [&](FDynamicPassMeshDrawListContext* DynamicMeshPassContext)
			{
				FDepthPassMeshProcessor PassMeshProcessor(
					EMeshPass::DepthPass,
					View.Family->Scene->GetRenderScene(),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileBasePassRendering.cpp:498

Scope (from outer to inner):

file
function     void FMobileSceneRenderer::RenderMobileEditorPrimitives

Source code excerpt:

	View.SimpleElementCollector.DrawBatchedElements(RHICmdList, DrawRenderState, View, EBlendModeFilter::OpaqueAndMasked, SDPG_Foreground);

	if (!View.Family->EngineShowFlags.CompositeEditorPrimitives)
	{
		DrawDynamicMeshPass(View, RHICmdList,
			[&View, &DrawRenderState](FDynamicPassMeshDrawListContext* DynamicMeshPassContext)
			{
				FEditorPrimitivesBasePassMeshProcessor PassMeshProcessor(
					View.Family->Scene->GetRenderScene(),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessCompositeEditorPrimitives.cpp:279

Scope: file

Source code excerpt:

	// The editor primitive composition pass is also used when rendering VMI_WIREFRAME in order to use MSAA.
	// So we need to check whether the editor primitives are enabled inside this function.
	if (View.Family->EngineShowFlags.CompositeEditorPrimitives)
	{
		// Populate depth if a prior pass did not already do it.
		if (!bProducedByPriorPass)
		{
			if (IsTemporalAccumulationBasedMethod(View.AntiAliasingMethod))
			{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessCompositeEditorPrimitives.cpp:409

Scope: file

Source code excerpt:


	// Draws the editor translucent primitives on top of the opaque scene primitives
	if (View.Family->EngineShowFlags.CompositeEditorPrimitives && View.bHasTranslucentViewMeshElements)
	{
		FEditorPrimitivesPassParameters* PassParameters = GraphBuilder.AllocParameters<FEditorPrimitivesPassParameters>();
		PassParameters->View = EditorView->GetShaderParameters();
		PassParameters->Scene = View.GetSceneUniforms().GetBuffer(GraphBuilder);
		PassParameters->ReflectionCapture = View.ReflectionCaptureUniformBuffer;
		PassParameters->MobileReflectionCaptureData = View.MobileReflectionCaptureUniformBuffer;

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

Scope (from outer to inner):

file
function     bool FSceneRenderer::ShouldCompositeEditorPrimitives

Source code excerpt:

		return true;
	}
	else if (ShowFlags.CompositeEditorPrimitives)
	{
	    // Any elements that needed compositing were drawn then compositing should be done
	    if (View.ViewMeshElements.Num() 
		    || View.TopViewMeshElements.Num() 
		    || View.BatchedViewElements.HasPrimsToDraw() 
		    || View.TopBatchedViewElements.HasPrimsToDraw() 

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:1178

Scope (from outer to inner):

file
function     static void RenderViewTranslucencyInner

Source code excerpt:

			}

			if (!View.Family->EngineShowFlags.CompositeEditorPrimitives)
			{
				QUICK_SCOPE_CYCLE_COUNTER(RenderTranslucencyParallel_SDPG_Foreground);

				DrawDynamicMeshPass(View, RHICmdList,
					[&View, &DrawRenderState, TranslucencyPass](FDynamicPassMeshDrawListContext* DynamicMeshPassContext)
				{