r.Shadow.SkipCullingNaniteMeshes
r.Shadow.SkipCullingNaniteMeshes
#Overview
name: r.Shadow.SkipCullingNaniteMeshes
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When enabled, CPU culling will ignore nanite meshes.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.SkipCullingNaniteMeshes is to control whether CPU culling should ignore Nanite meshes in the shadow rendering process. This setting variable is part of the Unreal Engine 5 rendering system, specifically related to shadow rendering and optimization.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the shadow setup and culling system. This can be seen from the file location “Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp”.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be changed at runtime through console commands. It’s initialized with a default value of 1 (enabled).
This variable interacts directly with its associated variable GSkipCullingNaniteMeshes. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable affects performance and rendering quality. When enabled (set to 1), CPU culling will ignore Nanite meshes, which can potentially improve performance but might affect shadow quality for Nanite objects.
Best practices when using this variable include:
- Testing the impact on performance and visual quality in your specific use case.
- Considering the trade-off between performance and shadow accuracy for Nanite meshes.
- Using it in conjunction with other shadow and Nanite-related settings for optimal results.
Regarding the associated variable GSkipCullingNaniteMeshes:
The purpose of GSkipCullingNaniteMeshes is the same as r.Shadow.SkipCullingNaniteMeshes, as they share the same value and functionality.
It’s used in the Renderer module, specifically in the shadow setup and culling process.
The value is set through the console variable r.Shadow.SkipCullingNaniteMeshes.
This variable directly interacts with r.Shadow.SkipCullingNaniteMeshes and is used in conditional statements to determine whether to skip culling for Nanite meshes.
Developers should be aware that this variable is used in performance-critical code paths related to shadow rendering and culling.
Best practices include carefully considering the performance implications of enabling or disabling this feature, especially in scenes with many Nanite meshes.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:106
Scope: file
Source code excerpt:
int32 GSkipCullingNaniteMeshes = 1;
FAutoConsoleVariableRef CVarSkipCullingNaniteMeshes(
TEXT("r.Shadow.SkipCullingNaniteMeshes"),
GSkipCullingNaniteMeshes,
TEXT("When enabled, CPU culling will ignore nanite meshes."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
/** Can be used to visualize preshadow frustums when the shadowfrustums show flag is enabled. */
#Associated Variable and Callsites
This variable is associated with another variable named GSkipCullingNaniteMeshes
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:104
Scope: file
Source code excerpt:
// Temporary chicken bit to back out optimization if there are any issues
int32 GSkipCullingNaniteMeshes = 1;
FAutoConsoleVariableRef CVarSkipCullingNaniteMeshes(
TEXT("r.Shadow.SkipCullingNaniteMeshes"),
GSkipCullingNaniteMeshes,
TEXT("When enabled, CPU culling will ignore nanite meshes."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
/** Can be used to visualize preshadow frustums when the shadowfrustums show flag is enabled. */
static TAutoConsoleVariable<int32> CVarDrawPreshadowFrustum(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:4790
Scope (from outer to inner):
file
function void AnyThreadTask
Source code excerpt:
// Nanite has its own culling
if (PrimitiveSceneInfoCompact.PrimitiveFlagsCompact.bCastDynamicShadow &&
(!PrimitiveSceneInfoCompact.PrimitiveFlagsCompact.bIsNaniteMesh || GSkipCullingNaniteMeshes == 0))
{
FilterPrimitiveForShadows(TaskData, PrimitiveSceneInfoCompact);
}
}
}
else
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:4807
Scope (from outer to inner):
file
function void AnyThreadTask
Source code excerpt:
// Nanite has its own culling
if (PrimitiveFlagsCompact.bCastDynamicShadow &&
(!PrimitiveFlagsCompact.bIsNaniteMesh || GSkipCullingNaniteMeshes == 0))
{
FPrimitiveSceneInfo* PrimitiveSceneInfo = TaskData.Scene->Primitives[PrimitiveIndex];
const FPrimitiveSceneInfoCompact PrimitiveSceneInfoCompact(PrimitiveSceneInfo);
FilterPrimitiveForShadows(TaskData, PrimitiveSceneInfoCompact);
}