r.Shadow.Virtual.Clipmap.FirstLevel
r.Shadow.Virtual.Clipmap.FirstLevel
#Overview
name: r.Shadow.Virtual.Clipmap.FirstLevel
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
First level of the virtual clipmap. Lower values allow higher resolution shadows closer to the camera, but may increase page count.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Virtual.Clipmap.FirstLevel is to control the first level of the virtual shadow map clipmap in Unreal Engine’s rendering system. This setting variable is specifically related to the virtual shadow mapping feature, which is part of the engine’s advanced shadow rendering capabilities.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the Virtual Shadow Maps subsystem. It’s defined and used in the VirtualShadowMapClipmap.cpp file, which suggests it’s integral to the virtual shadow map clipmap functionality.
The value of this variable is set through a console variable (CVar) system, allowing it to be adjusted at runtime. It’s initialized with a default value of 6, but can be changed through engine settings or console commands.
This variable interacts closely with another variable called CVarVirtualShadowMapClipmapLastLevel, which likely defines the last level of the clipmap. Together, these variables would define the range of the virtual shadow map clipmap.
Developers must be aware that this variable directly affects the resolution and performance of shadow rendering. As the description states, “Lower values allow higher resolution shadows closer to the camera, but may increase page count.” This means that while lowering the value can improve shadow quality near the camera, it may also increase memory usage and potentially impact performance.
Best practices when using this variable include:
- Balancing shadow quality with performance requirements.
- Testing different values to find the optimal setting for your specific game or application.
- Considering the target hardware when adjusting this value, as higher-end systems may be able to handle lower values (higher resolution) better than lower-end systems.
Regarding the associated variable CVarVirtualShadowMapClipmapFirstLevel:
This is the actual console variable object that stores and manages the r.Shadow.Virtual.Clipmap.FirstLevel setting. It’s defined as a TAutoConsoleVariable
The purpose of this variable is the same as r.Shadow.Virtual.Clipmap.FirstLevel - to control the first level of the virtual shadow map clipmap.
It’s used in the GetFirstLevel() function of the FVirtualShadowMapClipmap class, which suggests that this class is responsible for managing the virtual shadow map clipmap.
When working with this variable, developers should use the GetValueOnRenderThread() method to retrieve its current value, ensuring thread-safe access in render thread operations.
The best practices for using this variable are the same as those for r.Shadow.Virtual.Clipmap.FirstLevel, as they represent the same setting, just in different forms (one as a console command string, the other as a C++ variable).
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapClipmap.cpp:37
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarVirtualShadowMapClipmapFirstLevel(
TEXT( "r.Shadow.Virtual.Clipmap.FirstLevel" ),
6,
TEXT( "First level of the virtual clipmap. Lower values allow higher resolution shadows closer to the camera, but may increase page count." ),
ECVF_Scalability | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarVirtualShadowMapClipmapLastLevel(
TEXT( "r.Shadow.Virtual.Clipmap.LastLevel" ),
#Associated Variable and Callsites
This variable is associated with another variable named CVarVirtualShadowMapClipmapFirstLevel
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapClipmap.cpp:36
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarVirtualShadowMapClipmapFirstLevel(
TEXT( "r.Shadow.Virtual.Clipmap.FirstLevel" ),
6,
TEXT( "First level of the virtual clipmap. Lower values allow higher resolution shadows closer to the camera, but may increase page count." ),
ECVF_Scalability | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarVirtualShadowMapClipmapLastLevel(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapClipmap.cpp:453
Scope (from outer to inner):
file
function int32 FVirtualShadowMapClipmap::GetFirstLevel
Source code excerpt:
int32 FVirtualShadowMapClipmap::GetFirstLevel()
{
return CVarVirtualShadowMapClipmapFirstLevel.GetValueOnRenderThread();
}
uint32 FVirtualShadowMapClipmap::GetCoarsePageClipmapIndexMask()
{
uint32 BitMask = 0;