r.Shadow.NaniteUpdateStreaming
r.Shadow.NaniteUpdateStreaming
#Overview
name: r.Shadow.NaniteUpdateStreaming
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Produce Nanite geometry streaming requests from shadow map rendering.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.NaniteUpdateStreaming is to control whether Nanite geometry streaming requests are produced from shadow map rendering. This setting variable is part of Unreal Engine 5’s rendering system, specifically focusing on the shadow rendering and Nanite geometry streaming aspects.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the shadow depth rendering component. This can be seen from the file location where the variable is defined and used: “Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp”.
The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 1, meaning it’s enabled by default. The value can be changed at runtime through the console or configuration files.
This variable interacts closely with the Nanite geometry system, which is Unreal Engine 5’s micro-polygon geometry system. It specifically affects how Nanite geometry is streamed when rendering shadows.
Developers should be aware that this variable can impact performance and visual quality. Enabling it (set to 1) will cause the engine to generate streaming requests for Nanite geometry during shadow map rendering, which can improve shadow quality for Nanite objects but may also increase memory usage and streaming workload.
Best practices when using this variable include:
- Leave it enabled (default value of 1) unless experiencing performance issues related to geometry streaming.
- If disabling, monitor shadow quality on Nanite objects to ensure acceptable results.
- Consider adjusting this setting based on the target platform and hardware capabilities.
Regarding the associated variable CVarNaniteShadowsUpdateStreaming:
The purpose of CVarNaniteShadowsUpdateStreaming is to provide programmatic access to the r.Shadow.NaniteUpdateStreaming setting within the C++ code of the engine.
This variable is used directly in the rendering code to determine whether to update Nanite geometry streaming during shadow rendering. It’s accessed using the GetValueOnRenderThread() method, which ensures thread-safe access to the current value.
The value of CVarNaniteShadowsUpdateStreaming is set automatically by the console variable system based on the r.Shadow.NaniteUpdateStreaming setting.
Developers should be aware that this variable is used in performance-critical rendering code, so frequent changes to its value could potentially impact rendering performance.
Best practices for using CVarNaniteShadowsUpdateStreaming include:
- Use GetValueOnRenderThread() when accessing the value, as shown in the provided code examples.
- Avoid changing the value frequently during runtime, as it may cause inconsistent behavior or performance issues.
- When implementing new shadow rendering features, consider the state of this variable to ensure compatibility with Nanite geometry streaming.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:133
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarNaniteShadowsUpdateStreaming(
TEXT("r.Shadow.NaniteUpdateStreaming"),
1,
TEXT("Produce Nanite geometry streaming requests from shadow map rendering."),
ECVF_RenderThreadSafe);
extern int32 GNaniteShowStats;
extern int32 GEnableNonNaniteVSM;
#Associated Variable and Callsites
This variable is associated with another variable named CVarNaniteShadowsUpdateStreaming
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:132
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarNaniteShadowsUpdateStreaming(
TEXT("r.Shadow.NaniteUpdateStreaming"),
1,
TEXT("Produce Nanite geometry streaming requests from shadow map rendering."),
ECVF_RenderThreadSafe);
extern int32 GNaniteShowStats;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:1490
Scope (from outer to inner):
file
function static void RenderShadowDepthAtlasNanite
lambda-function
Source code excerpt:
Nanite::FConfiguration CullingConfig = { 0 };
CullingConfig.bTwoPassOcclusion = true;
CullingConfig.bUpdateStreaming = CVarNaniteShadowsUpdateStreaming.GetValueOnRenderThread() != 0;
CullingConfig.HiddenFilterFlags = HiddenFilterFlags;
CullingConfig.SetViewFlags(SceneView);
if (GNaniteShowStats != 0)
{
FString AtlasFilterName = FString::Printf(TEXT("ShadowAtlas%d"), AtlasIndex);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:1704
Scope (from outer to inner):
file
function void FSceneRenderer::RenderVirtualShadowMaps
Source code excerpt:
if (ShadowSceneRenderer)
{
ShadowSceneRenderer->RenderVirtualShadowMaps(GraphBuilder, bNaniteEnabled, CVarNaniteShadowsUpdateStreaming.GetValueOnRenderThread() != 0);
}
}
void FSceneRenderer::RenderShadowDepthMaps(FRDGBuilder& GraphBuilder, FDynamicShadowsTaskData* DynamicShadowsTaskData, FInstanceCullingManager &InstanceCullingManager, FRDGExternalAccessQueue& ExternalAccessQueue)
{
ensureMsgf(!bShadowDepthRenderCompleted, TEXT("RenderShadowDepthMaps called twice in the same frame"));
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:1780
Scope (from outer to inner):
file
function void FSceneRenderer::RenderShadowDepthMaps
Source code excerpt:
FRDGTextureRef RDGShadowMap = GraphBuilder.RegisterExternalTexture( ShadowMap.RenderTargets.DepthTarget, TEXT("ShadowDepthBuffer") );
const bool bUpdateStreaming = CVarNaniteShadowsUpdateStreaming.GetValueOnRenderThread() != 0;
FLightSceneInfo& LightSceneInfo = ProjectedShadowInfo->GetLightSceneInfo();
FString CubeFilterName;
if (GNaniteShowStats != 0)
{