r.Shadow.Virtual.Clipmap.GreedyLevelSelection
r.Shadow.Virtual.Clipmap.GreedyLevelSelection
#Overview
name: r.Shadow.Virtual.Clipmap.GreedyLevelSelection
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When enabled, allows greedily sampling more detailed clipmap levels if they happen to be mapped.\nThis can increase shadow quality from certain viewing angles, but makes the clipmap boundry less stable which can exacerbate visual artifacts at low shadow resolutions.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Virtual.Clipmap.GreedyLevelSelection is to control the sampling behavior of virtual shadow map clipmap levels in Unreal Engine’s rendering system. It is specifically related to the virtual shadow mapping feature, which is part of the engine’s advanced rendering capabilities.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the virtual shadow maps subsystem. Based on the callsites, it’s clear that this variable is utilized in the VirtualShadowMapArray.cpp file, which is responsible for managing virtual shadow map arrays.
The value of this variable is set through a console variable (CVarClipmapGreedyLevelSelection) with a default value of 0. It can be changed at runtime using console commands or through engine configuration files.
This variable interacts closely with its associated variable CVarClipmapGreedyLevelSelection. They share the same value and are used interchangeably in the code.
Developers must be aware that enabling this feature (setting it to 1) can have both positive and negative effects on shadow quality:
- It can increase shadow quality from certain viewing angles by allowing more detailed clipmap levels to be sampled.
- However, it can also make the clipmap boundary less stable, which may exacerbate visual artifacts, especially at low shadow resolutions.
Best practices when using this variable include:
- Testing the visual impact thoroughly in different scenarios before enabling it in production.
- Considering the trade-off between improved shadow quality and potential visual artifacts.
- Adjusting other shadow-related settings in conjunction with this one to achieve the best balance of quality and performance.
- Using it cautiously in projects where consistent shadow behavior is crucial, as it can introduce variability in shadow appearance.
Regarding the associated variable CVarClipmapGreedyLevelSelection: This is the actual console variable that controls the r.Shadow.Virtual.Clipmap.GreedyLevelSelection setting. It is defined as an integer (int32) and is marked with flags ECVF_Scalability and ECVF_RenderThreadSafe, indicating that it affects scalability and can be safely modified on the render thread.
The value of CVarClipmapGreedyLevelSelection is retrieved in the FVirtualShadowMapArray::Initialize function and stored in the UniformParameters.bClipmapGreedyLevelSelection field. This suggests that the setting is used during the initialization of virtual shadow map arrays and affects their behavior throughout the rendering process.
When working with this variable, developers should consider its impact on performance and visual consistency, especially when developing for multiple platforms with varying hardware capabilities.
#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:240
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarClipmapGreedyLevelSelection(
TEXT("r.Shadow.Virtual.Clipmap.GreedyLevelSelection"),
0,
TEXT("When enabled, allows greedily sampling more detailed clipmap levels if they happen to be mapped.\n")
TEXT("This can increase shadow quality from certain viewing angles, but makes the clipmap boundry less stable which can exacerbate visual artifacts at low shadow resolutions."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Associated Variable and Callsites
This variable is associated with another variable named CVarClipmapGreedyLevelSelection
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:239
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarClipmapGreedyLevelSelection(
TEXT("r.Shadow.Virtual.Clipmap.GreedyLevelSelection"),
0,
TEXT("When enabled, allows greedily sampling more detailed clipmap levels if they happen to be mapped.\n")
TEXT("This can increase shadow quality from certain viewing angles, but makes the clipmap boundry less stable which can exacerbate visual artifacts at low shadow resolutions."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:437
Scope (from outer to inner):
file
function void FVirtualShadowMapArray::Initialize
Source code excerpt:
UniformParameters.CoarsePagePixelThresholdStatic = CVarCoarsePagePixelThresholdStatic.GetValueOnRenderThread();
UniformParameters.CoarsePagePixelThresholdDynamicNanite = CVarCoarsePagePixelThresholdDynamicNanite.GetValueOnRenderThread();
UniformParameters.bClipmapGreedyLevelSelection = CVarClipmapGreedyLevelSelection.GetValueOnRenderThread();
UniformParameters.SceneFrameNumber = Scene.GetFrameNumberRenderThread();
// Reference dummy data in the UB initially
const uint32 DummyPageTableElement = 0xFFFFFFFF;
UniformParameters.PageTable = GraphBuilder.CreateSRV(GSystemTextures.GetDefaultStructuredBuffer(GraphBuilder, sizeof(DummyPageTableElement), DummyPageTableElement));