ShowFlag.NaniteMeshes
ShowFlag.NaniteMeshes
#Overview
name: ShowFlag.NaniteMeshes
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allows to override a specific showflag (works in editor and game, \
It is referenced in 23
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ShowFlag.NaniteMeshes is to control the rendering of Nanite meshes in Unreal Engine 5. Nanite is a virtualized geometry system that allows for highly detailed meshes with minimal performance impact.
This setting variable is primarily used by the rendering system, specifically for controlling the visibility of Nanite meshes in various rendering contexts. It is relied upon by several Unreal Engine subsystems and modules, including:
- The core rendering system
- The Nanite system
- The Landscape system
- The GeometryCollection system
- The Water plugin
The value of this variable is typically set through the engine’s show flags system, which allows for toggling various rendering features. It can be manipulated programmatically or through the engine’s user interface.
Other variables that interact with it include:
- UseNanite(ShaderPlatform): This is often used in conjunction with NaniteMeshes to determine if Nanite should be used.
- Nanite::GStreamingManager.HasResourceEntries(): This is checked to ensure there are Nanite resources available.
Developers should be aware that:
- Disabling NaniteMeshes will prevent Nanite geometry from rendering, which can be useful for debugging or performance testing.
- Some systems, like the water brush manager, explicitly disable NaniteMeshes for certain operations.
- The Landscape system uses this flag to determine if Nanite landscapes should be updated or rendered.
Best practices when using this variable include:
- Only disable it when necessary, as Nanite is a core feature for high-quality rendering in UE5.
- Be aware of its impact on various systems when toggling it, especially in custom rendering paths.
- Use it in conjunction with other Nanite-related settings for fine-grained control over the rendering pipeline.
The associated variable NaniteMeshes is used in similar contexts, particularly in the StaticMesh asset definition system. It’s used to count and manipulate Nanite-enabled meshes in the content browser and asset management systems. The same considerations apply to this variable in terms of its impact on Nanite functionality in the engine.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:444
Scope: file
Source code excerpt:
/** Draw Nanite meshes */
SHOWFLAG_ALWAYS_ACCESSIBLE(NaniteMeshes, SFG_Nanite, NSLOCTEXT("UnrealEd", "NaniteMeshesSF", "Meshes"))
/** Draw Nanite streaming geometry */
SHOWFLAG_ALWAYS_ACCESSIBLE(NaniteStreamingGeometry, SFG_Nanite, NSLOCTEXT("UnrealEd", "NaniteStreamingGeometrySF", "Streaming Geometry"))
/** Visualize Skin Cache */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeGPUSkinCache, SFG_Hidden, NSLOCTEXT("UnrealEd", "VisualizeGPUSkinCache", "Visualize GPU Skin Cache"))
#Associated Variable and Callsites
This variable is associated with another variable named NaniteMeshes
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Editor/EngineAssetDefinitions/Source/Private/AssetDefinition_StaticMesh.cpp:135
Scope (from outer to inner):
file
namespace MenuExtension_StaticMesh
function void ExecuteNaniteDisable
Source code excerpt:
{
const UContentBrowserAssetContextMenuContext* Context = UContentBrowserAssetContextMenuContext::FindContextWithAssets(InContext);
TArray<UStaticMesh*> NaniteMeshes = Context->LoadSelectedObjectsIf<UStaticMesh>([](const FAssetData& AssetData) {
return IsNaniteEnabled(AssetData);
});
ModifyNaniteEnable(NaniteMeshes, false);
}
static void GetNaniteMenu(UToolMenu* Menu)
{
const UContentBrowserAssetContextMenuContext* Context = UContentBrowserAssetContextMenuContext::FindContextWithAssets(*Menu);
#Loc: <Workspace>/Engine/Plugins/Editor/EngineAssetDefinitions/Source/Private/AssetDefinition_StaticMesh.cpp:187
Scope (from outer to inner):
file
namespace MenuExtension_StaticMesh
function static void GetNaniteMenu
Source code excerpt:
Section.AddSeparator("Nanite_EnableDisableOptions");
const int32 NaniteMeshes = Algo::Accumulate(Context->SelectedAssets, 0, [](int32 Value, const FAssetData& StaticMeshAsset)
{
bool bNaniteEnabled = false;
return (StaticMeshAsset.GetTagValue<bool>(NAME_NaniteEnabled, bNaniteEnabled) && bNaniteEnabled) ? Value + 1 : Value;
});
{
const int32 RegularMeshes = Context->SelectedAssets.Num() - NaniteMeshes;
const TAttribute<FText> Label = FText::Format(LOCTEXT("StaticMesh_NaniteEnableAll", "Enable Nanite ({0} Meshes)"), RegularMeshes);
const TAttribute<FText> ToolTip = LOCTEXT("StaticMesh_NaniteEnableAllTooltip", "Enables support for Nanite on the selected meshes.");
const FSlateIcon Icon = FSlateIcon();
FToolUIAction UIAction;
#Loc: <Workspace>/Engine/Plugins/Editor/EngineAssetDefinitions/Source/Private/AssetDefinition_StaticMesh.cpp:207
Scope (from outer to inner):
file
namespace MenuExtension_StaticMesh
function static void GetNaniteMenu
Source code excerpt:
{
const TAttribute<FText> Label = FText::Format(LOCTEXT("StaticMesh_NaniteDisableAll", "Disable Nanite ({0} Meshes)"), NaniteMeshes);
const TAttribute<FText> ToolTip = LOCTEXT("StaticMesh_NaniteDisableAllTooltip", "Disables support for Nanite on the selected meshes.");
const FSlateIcon Icon = FSlateIcon();
FToolUIAction UIAction;
UIAction.ExecuteAction = FToolMenuExecuteAction::CreateStatic(&ExecuteNaniteDisable);
UIAction.CanExecuteAction.BindLambda([NaniteMeshes](const FToolMenuContext&) { return NaniteMeshes > 0; });
Section.AddMenuEntry("StaticMesh_DisableNanite", Label, ToolTip, Icon, UIAction);
}
}
// LOD Section
//=================================================================
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Editor/Private/WaterBrushManager.cpp:52
Scope (from outer to inner):
file
function AWaterBrushManager::AWaterBrushManager
Source code excerpt:
SceneCaptureComponent2D->SetRelativeScale3D(FVector(0.01f, 0.01f, 0.01f));
// HACK [jonathan.bard] : Nanite doesn't support USceneCaptureComponent's ShowOnlyComponents ATM so just disable Nanite during captures :
SceneCaptureComponent2D->ShowFlagSettings.Add(FEngineShowFlagsSetting { TEXT("NaniteMeshes"), false } );
// These also need to be disabled to get a clean capture of just the water info material output
SceneCaptureComponent2D->ShowFlagSettings.Add(FEngineShowFlagsSetting { TEXT("Atmosphere"), false } );
SceneCaptureComponent2D->ShowFlagSettings.Add(FEngineShowFlagsSetting { TEXT("Bloom"), false } );
SceneCaptureComponent2D->ShowFlagSettings.Add(FEngineShowFlagsSetting { TEXT("Lighting"), false } );
PrimaryActorTick.TickGroup = ETickingGroup::TG_PrePhysics;
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterInfoRendering.cpp:642
Scope (from outer to inner):
file
namespace UE::WaterInfo
function static FSceneRenderer* CreateWaterInfoSceneRenderer
Source code excerpt:
FEngineShowFlags ShowFlags(ESFIM_Game);
ShowFlags.NaniteMeshes = 0;
ShowFlags.Atmosphere = 0;
ShowFlags.Lighting = 0;
ShowFlags.Bloom = 0;
ShowFlags.ScreenPercentage = 0;
ShowFlags.Translucency = 0;
ShowFlags.SeparateTranslucency = 0;
#Loc: <Workspace>/Engine/Plugins/Runtime/nDisplay/Source/DisplayCluster/Private/Render/Viewport/DisplayClusterViewportManager.cpp:657
Scope (from outer to inner):
file
function FSceneViewFamily::ConstructionValues FDisplayClusterViewportManager::CreateViewFamilyConstructionValues
Source code excerpt:
bool bResolveScene = true;
// Control NaniteMeshes for ChromaKey and Lightcards:
switch (InFrameTarget.CaptureMode)
{
case EDisplayClusterViewportCaptureMode::Chromakey:
if (!GDisplayClusterChromaKeyAllowNanite)
{
InEngineShowFlags.SetNaniteMeshes(0);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Rendering/NaniteResources.cpp:1019
Scope (from outer to inner):
file
namespace Nanite
function FPrimitiveViewRelevance FSceneProxy::GetViewRelevance
Source code excerpt:
FPrimitiveViewRelevance Result;
Result.bDrawRelevance = IsShown(View) && View->Family->EngineShowFlags.NaniteMeshes;
Result.bShadowRelevance = IsShadowCast(View);
Result.bRenderCustomDepth = Nanite::GetSupportsCustomDepthRendering() && ShouldRenderCustomDepth();
Result.bUsesLightingChannels = GetLightingChannelMask() != GetDefaultLightingChannelMask();
// Always render the Nanite mesh data with static relevance.
Result.bStaticRelevance = true;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShowFlags.cpp:656
Scope (from outer to inner):
file
function void EngineShowFlagOverride
Source code excerpt:
DISABLE_ENGINE_SHOWFLAG(SkeletalMeshes)
DISABLE_ENGINE_SHOWFLAG(StaticMeshes)
DISABLE_ENGINE_SHOWFLAG(NaniteMeshes)
DISABLE_ENGINE_SHOWFLAG(BSP)
DISABLE_ENGINE_SHOWFLAG(Paper2DSprites)
#undef DISABLE_ENGINE_SHOWFLAG
}
}
#endif
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:444
Scope: file
Source code excerpt:
/** Draw Nanite meshes */
SHOWFLAG_ALWAYS_ACCESSIBLE(NaniteMeshes, SFG_Nanite, NSLOCTEXT("UnrealEd", "NaniteMeshesSF", "Meshes"))
/** Draw Nanite streaming geometry */
SHOWFLAG_ALWAYS_ACCESSIBLE(NaniteStreamingGeometry, SFG_Nanite, NSLOCTEXT("UnrealEd", "NaniteStreamingGeometrySF", "Streaming Geometry"))
/** Visualize Skin Cache */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeGPUSkinCache, SFG_Hidden, NSLOCTEXT("UnrealEd", "VisualizeGPUSkinCache", "Visualize GPU Skin Cache"))
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionSceneProxy.cpp:1159
Scope (from outer to inner):
file
function FPrimitiveViewRelevance FNaniteGeometryCollectionSceneProxy::GetViewRelevance
Source code excerpt:
FPrimitiveViewRelevance Result;
Result.bDrawRelevance = IsShown(View) && View->Family->EngineShowFlags.NaniteMeshes;
Result.bShadowRelevance = IsShadowCast(View);
Result.bRenderCustomDepth = Nanite::GetSupportsCustomDepthRendering() && ShouldRenderCustomDepth();
Result.bUsesLightingChannels = GetLightingChannelMask() != GetDefaultLightingChannelMask();
// Always render the Nanite mesh data with static relevance.
Result.bStaticRelevance = true;
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/Landscape.cpp:6443
Scope (from outer to inner):
file
function UE::Landscape::EOutdatedDataFlags ALandscapeProxy::GetOutdatedDataFlags
Source code excerpt:
if (!IsNaniteMeshUpToDate())
{
OutdatedDataFlags |= UE::Landscape::EOutdatedDataFlags::NaniteMeshes;
}
return OutdatedDataFlags;
}
void ALandscapeProxy::ClearNaniteTransactional()
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeRender.cpp:2120
Scope: file
Source code excerpt:
#endif // !UE_BUILD_SHIPPING
if (bNaniteActive && View->Family->EngineShowFlags.NaniteMeshes && !View->CustomRenderPass)
{
Result.bShadowRelevance = false;
Result.bVelocityRelevance = false;
Result.bRenderCustomDepth = false;
Result.bTranslucentSelfShadow = false;
#if WITH_EDITOR
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeRender.cpp:4507
Scope (from outer to inner):
file
function bool FLandscapeComponentSceneProxy::ShouldInvalidateShadows
Source code excerpt:
if (WorldSpaceMipToMipMaxDeltas.IsEmpty() // Only apply if we have computed the error estimates
|| !GLandscapeAllowNonNaniteVirtualShadowMapInvalidation // Global switch
|| (bNaniteActive && InView.Family->EngineShowFlags.NaniteMeshes) // Only applies if Nanite is not active
|| (VirtualShadowMapInvalidationHeightErrorThreshold <= 0.0f)) // Only applies if the threshold is valid
{
return false;
}
// We want to estimate the height error between the height at the current LOD transition and the height at which the last shadow invalidation took place
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeSubsystem.cpp:891
Scope (from outer to inner):
file
function bool ULandscapeSubsystem::GetActionableMessage
Source code excerpt:
const TArray<ALandscapeProxy*> OutdatedGrassMapProxies = GetOutdatedProxies(UE::Landscape::EOutdatedDataFlags::GrassMaps, /*bInMustMatchAllFlags = */false);
const TArray<ALandscapeProxy*> OutdatedPhysicalMaterialProxies = GetOutdatedProxies(UE::Landscape::EOutdatedDataFlags::PhysicalMaterials, /*bInMustMatchAllFlags = */false);
const TArray<ALandscapeProxy*> OutdatedNaniteProxies = GetOutdatedProxies(UE::Landscape::EOutdatedDataFlags::NaniteMeshes, /*bInMustMatchAllFlags = */false);
const int32 OutdatedGrassmapProxiesCount = OutdatedGrassMapProxies.Num();
const int32 OutdatedPhysicalMaterialProxiesCount = OutdatedPhysicalMaterialProxies.Num();
const int32 OutdatedNaniteProxiesCount = OutdatedNaniteProxies.Num();
const int32 OutdatedFlags = ((OutdatedGrassmapProxiesCount > 0) ? 1 : 0) + ((OutdatedPhysicalMaterialProxiesCount > 0) ? 1 : 0) + ((OutdatedNaniteProxiesCount > 0) ? 1 : 0);
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Public/LandscapeEditTypes.h:23
Scope (from outer to inner):
file
namespace UE::Landscape
Source code excerpt:
GrassMaps = (1 << 0),
PhysicalMaterials = (1 << 1),
NaniteMeshes = (1 << 2),
// TODO [jonathan.bard] : DirtyActors = (1 << 3) ?
All = (GrassMaps | PhysicalMaterials | NaniteMeshes /*| DirtyActors*/)
};
ENUM_CLASS_FLAGS(EOutdatedDataFlags);
} // namespace UE::Landscape
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:429
Scope (from outer to inner):
file
function bool FDeferredShadingSceneRenderer::ShouldRenderNanite
Source code excerpt:
bool FDeferredShadingSceneRenderer::ShouldRenderNanite() const
{
return UseNanite(ShaderPlatform) && ViewFamily.EngineShowFlags.NaniteMeshes && Nanite::GStreamingManager.HasResourceEntries();
}
bool FDeferredShadingSceneRenderer::RenderHzb(FRDGBuilder& GraphBuilder, FRDGTextureRef SceneDepthTexture, const FBuildHZBAsyncComputeParams* AsyncComputeParams)
{
RDG_GPU_STAT_SCOPE(GraphBuilder, HZB);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:1136
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::CommitFinalPipelineState
Source code excerpt:
// Family pipeline state
{
FamilyPipelineState.Set(&FFamilyPipelineState::bNanite, UseNanite(ShaderPlatform)); // TODO: Should this respect ViewFamily.EngineShowFlags.NaniteMeshes?
static const auto ICVarHZBOcc = IConsoleManager::Get().FindConsoleVariable(TEXT("r.HZBOcclusion"));
FamilyPipelineState.Set(&FFamilyPipelineState::bHZBOcclusion, ICVarHZBOcc->GetInt() != 0);
}
CommitIndirectLightingState();
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneRendering.cpp:2226
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::UpdateLumenScene
Source code excerpt:
}
if (UseNanite(ShaderPlatform) && ViewFamily.EngineShowFlags.NaniteMeshes && bAnyNaniteMeshes)
{
QUICK_SCOPE_CYCLE_COUNTER(NaniteMeshPass);
const FIntPoint DepthStencilAtlasSize = CardCaptureAtlas.Size;
const FIntRect DepthAtlasRect = FIntRect(0, 0, DepthStencilAtlasSize.X, DepthStencilAtlasSize.Y);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteShared.cpp:352
Scope (from outer to inner):
file
function bool ShouldRenderNanite
Source code excerpt:
{
// Is the view family showing Nanite meshes?
return View.Family->EngineShowFlags.NaniteMeshes;
}
}
// Nanite should not render for this view
return false;
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteShared.cpp:366
Scope (from outer to inner):
file
function bool WouldRenderNanite
Source code excerpt:
{
// Is the view family showing would-be Nanite meshes?
return View.Family->EngineShowFlags.NaniteMeshes;
}
// Nanite would not render for this view
return false;
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:1581
Scope (from outer to inner):
file
function void FSceneRenderer::RenderShadowDepthMapAtlases
Source code excerpt:
const bool bNaniteEnabled =
UseNanite(ShaderPlatform) &&
ViewFamily.EngineShowFlags.NaniteMeshes &&
CVarNaniteShadows.GetValueOnRenderThread() != 0 &&
Nanite::GStreamingManager.HasResourceEntries();
Scene->PrevAtlasHZBs.SetNum(SortedShadowsForShadowDepthPass.ShadowMapAtlases.Num());
FRDGExternalAccessQueue ExternalAccessQueue;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:1732
Scope (from outer to inner):
file
function void FSceneRenderer::RenderShadowDepthMaps
Source code excerpt:
const bool bNaniteEnabled =
UseNanite(ShaderPlatform) &&
ViewFamily.EngineShowFlags.NaniteMeshes &&
Nanite::GStreamingManager.HasResourceEntries();
RenderVirtualShadowMaps(GraphBuilder, bNaniteEnabled);
// Render non-VSM shadows
RenderShadowDepthMapAtlases(GraphBuilder);