r.Shadow.Virtual.NonNanite.Batch
r.Shadow.Virtual.NonNanite.Batch
#Overview
name: r.Shadow.Virtual.NonNanite.Batch
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Virtual.NonNanite.Batch is to control the batching behavior for non-Nanite objects in virtual shadow maps within Unreal Engine 5’s rendering system.
This setting variable is primarily used in the rendering system, specifically in the virtual shadow mapping subsystem. Based on the callsites, it’s part of the Renderer module, focusing on virtual shadow map implementation.
The value of this variable is set through a console variable (CVarDoNonNaniteBatching) with a default value of 1, indicating that batching is enabled by default. It can be modified at runtime using console commands or through project settings.
The associated variable CVarDoNonNaniteBatching directly interacts with r.Shadow.Virtual.NonNanite.Batch. They share the same value and purpose, with CVarDoNonNaniteBatching being the C++ representation of the console variable.
Developers should be aware that this variable affects the performance and rendering of virtual shadow maps for non-Nanite objects. When enabled (value != 0), it allows for batching of these objects during shadow rendering, which can potentially improve performance.
Best practices when using this variable include:
- Leave it enabled (default value of 1) unless specific issues are encountered.
- If performance problems arise with virtual shadow maps for non-Nanite objects, experiment with disabling this feature to isolate the issue.
- Monitor performance metrics when modifying this value, as it can impact rendering efficiency.
Regarding the associated variable CVarDoNonNaniteBatching:
- It’s the C++ representation of the r.Shadow.Virtual.NonNanite.Batch console variable.
- It’s used directly in the code to check whether batching should be performed (CVarDoNonNaniteBatching.GetValueOnRenderThread() != 0).
- The variable is defined as thread-safe (ECVF_RenderThreadSafe), allowing it to be safely accessed from the render thread.
- Developers should use this variable when implementing custom rendering logic that interacts with virtual shadow maps for non-Nanite objects, ensuring consistency with the engine’s batching behavior.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:203
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarDoNonNaniteBatching(
TEXT("r.Shadow.Virtual.NonNanite.Batch"),
1,
TEXT("."),
ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarCoarsePagePixelThresholdDynamic(
#Associated Variable and Callsites
This variable is associated with another variable named CVarDoNonNaniteBatching
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:202
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarDoNonNaniteBatching(
TEXT("r.Shadow.Virtual.NonNanite.Batch"),
1,
TEXT("."),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:2773
Scope (from outer to inner):
file
function void FVirtualShadowMapArray::RenderVirtualShadowMapsNonNanite
Source code excerpt:
ShadowsToAddRenderViews.Add(ProjectedShadowInfo);
if (CVarDoNonNaniteBatching.GetValueOnRenderThread() != 0)
{
// NOTE: This array must be 1:1 with the batches inside the InstanceCullingMergedContext, which is guaranteed by checking HasCullingCommands() above (and checked in the merged context)
// If we were to defer/async this process, we need to maintain this property or add some remapping.
VSMCullingBatchInfos.Add(VSMCullingBatchInfo);
// Note: we have to allocate these up front as the context merging machinery writes the offsets directly to the &PassParameters->InstanceCullingDrawParams,