r.Shadow.Virtual.NonNanite.SinglePassBatched

r.Shadow.Virtual.NonNanite.SinglePassBatched

#Overview

name: r.Shadow.Virtual.NonNanite.SinglePassBatched

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Shadow.Virtual.NonNanite.SinglePassBatched is to control the batching of non-Nanite virtual shadow map rendering in a single pass. This setting is part of Unreal Engine 5’s virtual shadow map system, which is a component of the rendering subsystem.

The Unreal Engine rendering subsystem relies on this setting variable, specifically within the virtual shadow map implementation. It is used in the VirtualShadowMapArray.cpp file, which is part of the Renderer module.

The value of this variable is set through a console variable (CVar) named CVarVirtualShadowSinglePassBatched. It is initialized with a default value of 1, indicating that single-pass batched rendering for non-Nanite virtual shadow maps is enabled by default.

The associated variable CVarVirtualShadowSinglePassBatched directly interacts with r.Shadow.Virtual.NonNanite.SinglePassBatched. They share the same value and purpose.

Developers must be aware that this variable affects the performance and potentially the quality of virtual shadow map rendering for non-Nanite objects. When enabled (set to 1), it allows for more efficient rendering by batching shadow map generation in a single pass.

Best practices when using this variable include:

  1. Keeping it enabled (set to 1) for better performance in most cases.
  2. Experimenting with disabling it (set to 0) if encountering specific issues with virtual shadow maps for non-Nanite objects.
  3. Profiling the rendering performance with both settings to determine the optimal configuration for your specific game or application.

Regarding the associated variable CVarVirtualShadowSinglePassBatched:

#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:329

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarVirtualShadowSinglePassBatched(
	TEXT("r.Shadow.Virtual.NonNanite.SinglePassBatched"),
	1,
	TEXT("."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarVirtualShadowMapPageMarkingPixelStrideX(
	TEXT("r.Shadow.Virtual.PageMarkingPixelStrideX"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:328

Scope: file

Source code excerpt:



static TAutoConsoleVariable<int32> CVarVirtualShadowSinglePassBatched(
	TEXT("r.Shadow.Virtual.NonNanite.SinglePassBatched"),
	1,
	TEXT("."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarVirtualShadowMapPageMarkingPixelStrideX(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:2910

Scope (from outer to inner):

file
function     void FVirtualShadowMapArray::RenderVirtualShadowMapsNonNanite

Source code excerpt:

		if(!BatchedVirtualSmMeshCommandPasses.IsEmpty())
		{
			if (CVarVirtualShadowSinglePassBatched.GetValueOnRenderThread() != 0)
			{
				FVirtualShadowDepthPassParameters* PassParameters = GraphBuilder.AllocParameters<FVirtualShadowDepthPassParameters>();
				FProjectedShadowInfo* ProjectedShadowInfo0 = BatchedVirtualSmMeshCommandPasses[0];
				FViewInfo* ShadowDepthView = ProjectedShadowInfo0->ShadowDepthView;

				PassParameters->View = ShadowDepthView->ViewUniformBuffer;