ShowFlag.InstancedFoliage

ShowFlag.InstancedFoliage

#Overview

name: ShowFlag.InstancedFoliage

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

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.InstancedFoliage is to control the visibility of instanced foliage in the rendering system of Unreal Engine 5. This setting variable is primarily used for managing the display of foliage elements in the game or editor view.

Unreal Engine subsystems that rely on this setting variable include:

  1. The rendering system, particularly the Nanite renderer
  2. The foliage system
  3. The Hierarchical Instanced Static Mesh (HISM) system

The value of this variable is set through the engine’s show flags system, which is typically controlled via the editor interface or programmatically through the engine’s API.

This variable interacts with other variables related to instanced meshes and foliage rendering, such as InstancedStaticMeshes and InstancedGrass.

Developers should be aware that:

  1. This flag affects the visibility of all instanced foliage in the scene.
  2. It’s used in view relevance calculations, which determine whether certain objects should be rendered.
  3. It’s accessible in both editor and game modes, as indicated by the SHOWFLAG_ALWAYS_ACCESSIBLE macro.

Best practices when using this variable include:

  1. Use it to toggle foliage visibility for performance optimization or debugging purposes.
  2. Consider its impact on other systems that rely on foliage visibility, such as gameplay mechanics or visual effects.
  3. Be cautious when modifying this flag during runtime, as it can affect performance and visual consistency.

Regarding the associated variable InstancedFoliage:

The purpose of InstancedFoliage is to represent instanced foliage in the engine’s foliage system. It’s used in various parts of the engine to handle the creation, rendering, and management of foliage instances.

This variable is primarily used in the Foliage module of Unreal Engine, as evidenced by its inclusion in the InstancedFoliage.cpp and InstancedFoliage.h files.

The value of this variable is set and managed by the foliage system, typically when creating or modifying foliage instances in the world.

It interacts closely with the ShowFlag.InstancedFoliage variable, as the show flag controls the visibility of the instanced foliage represented by this variable.

Developers should be aware that:

  1. This variable represents the core functionality of the foliage system in Unreal Engine.
  2. It’s used in various rendering and scene management processes.
  3. Modifications to this system can have wide-ranging effects on performance and visual fidelity.

Best practices when working with InstancedFoliage include:

  1. Use the provided Unreal Engine API for foliage manipulation rather than directly modifying the underlying data.
  2. Consider performance implications when working with large amounts of instanced foliage.
  3. Utilize the foliage tools provided in the Unreal Editor for efficient foliage placement and management.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(InstancedStaticMeshes, SFG_Advanced, NSLOCTEXT("UnrealEd", "InstancedStaticMeshesSF", "Instanced Static Meshes"))
/** Draws instanced foliage, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(InstancedFoliage, SFG_Advanced, NSLOCTEXT("UnrealEd", "InstancedFoliageSF", "Foliage"))
/** Allow to see the foliage bounds used in the occlusion test */
SHOWFLAG_FIXED_IN_SHIPPING(0, HISMCOcclusionBounds, SFG_Advanced, NSLOCTEXT("UnrealEd", "HISMOcclusionBoundsSF", "HISM/Foliage Occlusion Bounds"))
/** Allow to see the cluster tree bounds used used to generate the occlusion bounds and in the culling */
SHOWFLAG_FIXED_IN_SHIPPING(0, HISMCClusterTree, SFG_Advanced, NSLOCTEXT("UnrealEd", "HISMClusterTreeSF", "HISM/Foliage Cluster Tree"))
/** Allow to see where each instance is in each ISM Component */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeInstanceUpdates, SFG_Advanced, NSLOCTEXT("UnrealEd", "VisualizeInstanceUpdatesSF", "Visualize Instance Updates"))

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/HierarchicalInstancedStaticMesh.cpp:874

Scope (from outer to inner):

file
function     FPrimitiveViewRelevance FHierarchicalStaticMeshSceneProxy::GetViewRelevance

Source code excerpt:

		break;
	case EHISMViewRelevanceType::Foliage:
		bShowInstancedMesh = View->Family->EngineShowFlags.InstancedFoliage;
		break;
	case EHISMViewRelevanceType::HISM:
		bShowInstancedMesh = View->Family->EngineShowFlags.InstancedStaticMeshes;
		break;
	default:
		break;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PrimitiveSceneProxy.cpp:1448

Scope (from outer to inner):

file
function     bool FPrimitiveSceneProxy::IsShown

Source code excerpt:

	}

	if (bIsFoliage && !View->Family->EngineShowFlags.InstancedFoliage)
	{
		return false;
	}

	// After checking for VR/Desktop Edit mode specific actors, check for Editor vs. Game
	if(View->Family->EngineShowFlags.Editor)

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

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(InstancedStaticMeshes, SFG_Advanced, NSLOCTEXT("UnrealEd", "InstancedStaticMeshesSF", "Instanced Static Meshes"))
/** Draws instanced foliage, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(InstancedFoliage, SFG_Advanced, NSLOCTEXT("UnrealEd", "InstancedFoliageSF", "Foliage"))
/** Allow to see the foliage bounds used in the occlusion test */
SHOWFLAG_FIXED_IN_SHIPPING(0, HISMCOcclusionBounds, SFG_Advanced, NSLOCTEXT("UnrealEd", "HISMOcclusionBoundsSF", "HISM/Foliage Occlusion Bounds"))
/** Allow to see the cluster tree bounds used used to generate the occlusion bounds and in the culling */
SHOWFLAG_FIXED_IN_SHIPPING(0, HISMCClusterTree, SFG_Advanced, NSLOCTEXT("UnrealEd", "HISMClusterTreeSF", "HISM/Foliage Cluster Tree"))
/** Allow to see where each instance is in each ISM Component */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeInstanceUpdates, SFG_Advanced, NSLOCTEXT("UnrealEd", "VisualizeInstanceUpdatesSF", "Visualize Instance Updates"))

#Loc: <Workspace>/Engine/Source/Runtime/Foliage/Private/InstancedFoliage.cpp:1

Scope: file

Source code excerpt:


/*=============================================================================
InstancedFoliage.cpp: Instanced foliage implementation.
=============================================================================*/

#include "InstancedFoliage.h"
#include "Templates/SubclassOf.h"
#include "HAL/IConsoleManager.h"
#include "GameFramework/DamageType.h"
#include "Engine/EngineTypes.h"
#include "Components/SceneComponent.h"

#Loc: <Workspace>/Engine/Source/Runtime/Foliage/Public/InstancedFoliage.h:1

Scope: file

Source code excerpt:


/*=============================================================================
InstancedFoliage.h: Instanced foliage type definitions.
=============================================================================*/
#pragma once

#include "CoreMinimal.h"
#include "Misc/Guid.h"
#include "Containers/ArrayView.h"
#include "FoliageInstanceBase.h"
#include "Instances/InstancedPlacementHash.h"

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:3028

Scope (from outer to inner):

file
namespace    Nanite
function     void FRenderer::AddPass_PrimitiveFilter

Source code excerpt:

	}

	if (!SceneView.Family->EngineShowFlags.InstancedFoliage)
	{
		HiddenFilterFlags |= EFilterFlags::Foliage;
	}

	if (!SceneView.Family->EngineShowFlags.InstancedGrass)
	{