r.Shadow.Virtual.Clipmap.MinCameraViewportWidth
r.Shadow.Virtual.Clipmap.MinCameraViewportWidth
#Overview
name: r.Shadow.Virtual.Clipmap.MinCameraViewportWidth
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If greater than zero, clamps the camera viewport dimensions used to adjust the clipmap resolution.\nThis can be useful to avoid dynamic resolution indirectly dropping the shadow resolution far too low.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Virtual.Clipmap.MinCameraViewportWidth is to control the minimum width of the camera viewport used for adjusting the virtual shadow map clipmap resolution. This setting is part of Unreal Engine 5’s rendering system, specifically the virtual shadow map feature.
This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the virtual shadow map subsystem. It’s referenced in the VirtualShadowMapClipmap.cpp file, which handles the implementation of virtual shadow map clipmaps.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0 and can be changed at runtime using console commands or through configuration files.
The associated variable CVarVirtualShadowMapClipmapMinCameraViewportWidth directly interacts with r.Shadow.Virtual.Clipmap.MinCameraViewportWidth. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable only takes effect when set to a value greater than zero. When active, it clamps the camera viewport dimensions used to adjust the clipmap resolution. This can be particularly useful in scenarios where dynamic resolution might indirectly cause the shadow resolution to drop too low.
Best practices when using this variable include:
- Only set it to a non-zero value when you need to prevent shadow resolution from dropping too low due to dynamic resolution.
- Carefully consider the performance implications of setting a high minimum viewport width, as it may impact rendering performance.
- Test thoroughly with various dynamic resolution settings to ensure the desired balance between performance and shadow quality.
Regarding the associated variable CVarVirtualShadowMapClipmapMinCameraViewportWidth:
This is the actual console variable that controls the r.Shadow.Virtual.Clipmap.MinCameraViewportWidth setting. It’s defined as an integer (int32) and is used to retrieve the current value of the setting in the render thread.
The purpose and usage of CVarVirtualShadowMapClipmapMinCameraViewportWidth are identical to r.Shadow.Virtual.Clipmap.MinCameraViewportWidth. It’s used in the FVirtualShadowMapClipmap constructor to optionally clamp the camera viewport width, which in turn affects the shadow map resolution.
Developers should be aware that changes to this variable will take effect on the render thread, as indicated by the ECVF_RenderThreadSafe flag in its declaration. This means that changes will be applied safely without causing thread synchronization issues.
When working with this variable, it’s important to consider its impact on both shadow quality and performance, and to test thoroughly across different hardware configurations to ensure optimal results.
#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:71
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarVirtualShadowMapClipmapMinCameraViewportWidth(
TEXT("r.Shadow.Virtual.Clipmap.MinCameraViewportWidth"),
0,
TEXT("If greater than zero, clamps the camera viewport dimensions used to adjust the clipmap resolution.\n")
TEXT("This can be useful to avoid dynamic resolution indirectly dropping the shadow resolution far too low."),
ECVF_RenderThreadSafe
);
#Associated Variable and Callsites
This variable is associated with another variable named CVarVirtualShadowMapClipmapMinCameraViewportWidth
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapClipmap.cpp:70
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarVirtualShadowMapClipmapMinCameraViewportWidth(
TEXT("r.Shadow.Virtual.Clipmap.MinCameraViewportWidth"),
0,
TEXT("If greater than zero, clamps the camera viewport dimensions used to adjust the clipmap resolution.\n")
TEXT("This can be useful to avoid dynamic resolution indirectly dropping the shadow resolution far too low."),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapClipmap.cpp:157
Scope (from outer to inner):
file
function FVirtualShadowMapClipmap::FVirtualShadowMapClipmap
Source code excerpt:
// Optionally clamp camera viewport to avoid excessively low resolution shadows with dynamic resolution
const int32 MinCameraViewportWidth = CVarVirtualShadowMapClipmapMinCameraViewportWidth.GetValueOnRenderThread();
bool bIsOrthographicCamera = !CameraViewMatrices.IsPerspectiveProjection();
int32 CameraViewportWidth = CameraViewRectSize.X;
if (bIsOrthographicCamera)
{
/**