r.Shadow.Virtual.Clipmap.UseConservativeCulling
r.Shadow.Virtual.Clipmap.UseConservativeCulling
#Overview
name: r.Shadow.Virtual.Clipmap.UseConservativeCulling
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Conservative culling removes the frustum-clipped culling volume for the non-nanite geometry for VSM rendering. This means a lot more geometry is submitted, and also marked as rendered.\nUseful to diagnose if there are culling artifacts in virtual shadow map clip maps due to errors in the tracking code.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Virtual.Clipmap.UseConservativeCulling is to control the culling behavior for virtual shadow map clip maps in Unreal Engine 5’s rendering system. It specifically affects how geometry is culled when rendering Virtual Shadow Maps (VSM) for non-Nanite geometry.
This setting variable is primarily used by the rendering system, particularly in the shadow rendering and culling subsystems. Based on the callsites, it’s clear that this variable is utilized in the following Unreal Engine modules:
- Renderer module (ShadowSetup.cpp, ShadowSceneRenderer.cpp, VirtualShadowMapArray.cpp)
The value of this variable is set through a console variable (CVarClipmapUseConservativeCulling) with a default value of 0. This means conservative culling is disabled by default.
The associated variable CVarClipmapUseConservativeCulling directly interacts with r.Shadow.Virtual.Clipmap.UseConservativeCulling, as they share the same value and purpose.
Developers must be aware of the following when using this variable:
- Enabling conservative culling (setting the value to non-zero) removes the frustum-clipped culling volume for non-Nanite geometry in VSM rendering.
- When enabled, more geometry is submitted and marked as rendered, which can impact performance.
- It’s primarily used for diagnosing culling artifacts in virtual shadow map clip maps that might be caused by errors in the tracking code.
Best practices when using this variable include:
- Keep it disabled (set to 0) for optimal performance in most scenarios.
- Enable it temporarily when investigating shadow culling artifacts or issues related to virtual shadow map clip maps.
- Be aware of the performance impact when enabling this feature, especially in performance-critical situations.
Regarding the associated variable CVarClipmapUseConservativeCulling:
The purpose of CVarClipmapUseConservativeCulling is identical to r.Shadow.Virtual.Clipmap.UseConservativeCulling. It’s an auto console variable that controls the same functionality.
This variable is used in the Renderer module, specifically in the shadow setup and projection calculations.
The value is set when the console variable is created, with a default of 0.
It directly interacts with r.Shadow.Virtual.Clipmap.UseConservativeCulling, as they represent the same setting.
Developers should be aware that this is the actual variable used in the code to check the setting’s value, while r.Shadow.Virtual.Clipmap.UseConservativeCulling is the console command to modify it.
Best practices for CVarClipmapUseConservativeCulling are the same as those for r.Shadow.Virtual.Clipmap.UseConservativeCulling, as they are essentially the same setting.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:315
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarClipmapUseConservativeCulling(
TEXT("r.Shadow.Virtual.Clipmap.UseConservativeCulling"),
0,
TEXT("Conservative culling removes the frustum-clipped culling volume for the non-nanite geometry for VSM rendering. This means a lot more geometry is submitted, and also marked as rendered.\n")
TEXT("Useful to diagnose if there are culling artifacts in virtual shadow map clip maps due to errors in the tracking code."),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Shadows/ShadowSceneRenderer.cpp:298
Scope (from outer to inner):
file
function void FShadowSceneRenderer::PostInitDynamicShadowsSetup
Source code excerpt:
const bool bIsCached = VirtualShadowMapArray.CacheManager->IsCacheEnabled() && GForceInvalidateDirectionalVSM == 0;
// We can only do this culling if the light is both uncached & it is using the accurate bounds (i.e., r.Shadow.Virtual.Clipmap.UseConservativeCulling is turned off).
if (!bIsCached && !ProjectedShadowInfo->CascadeSettings.ShadowBoundsAccurate.Planes.IsEmpty())
{
NaniteCullingViewsVolumes.Add(ProjectedShadowInfo->CascadeSettings.ShadowBoundsAccurate);
}
else
{
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:2519
Scope (from outer to inner):
file
function static FCullingVolume GetCullingVolume
Source code excerpt:
const bool bIsCached = ProjectedShadowInfo->VirtualShadowMapClipmap->GetCacheEntry() && !ProjectedShadowInfo->VirtualShadowMapClipmap->GetCacheEntry()->IsUncached();
// We can only do this culling if the light is both uncached & it is using the accurate bounds (i.e., r.Shadow.Virtual.Clipmap.UseConservativeCulling is turned off).
if (!bIsCached && !ProjectedShadowInfo->CascadeSettings.ShadowBoundsAccurate.Planes.IsEmpty())
{
CullingVolume.ConvexVolume = ProjectedShadowInfo->CascadeSettings.ShadowBoundsAccurate;
}
else
{
#Associated Variable and Callsites
This variable is associated with another variable named CVarClipmapUseConservativeCulling
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:314
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarClipmapUseConservativeCulling(
TEXT("r.Shadow.Virtual.Clipmap.UseConservativeCulling"),
0,
TEXT("Conservative culling removes the frustum-clipped culling volume for the non-nanite geometry for VSM rendering. This means a lot more geometry is submitted, and also marked as rendered.\n")
TEXT("Useful to diagnose if there are culling artifacts in virtual shadow map clip maps due to errors in the tracking code."),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:1119
Scope (from outer to inner):
file
function void FProjectedShadowInfo::SetupClipmapProjection
Source code excerpt:
ReceiverInnerFrustum = CasterOuterFrustum;
if (CVarClipmapUseConservativeCulling.GetValueOnRenderThread() != 0)
{
ShadowBounds = VirtualShadowMapClipmap->GetBoundingSphere();
CascadeSettings.ShadowBoundsAccurate = VirtualShadowMapClipmap->GetViewFrustumBounds();
}
else
{