r.VolumetricCloud.ShadowMap.SpatialFiltering
r.VolumetricCloud.ShadowMap.SpatialFiltering
#Overview
name: r.VolumetricCloud.ShadowMap.SpatialFiltering
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable/disable the shadow map dilation/smoothing spatial filter. Enabled when greater than 0 and it represents the number of blur iterations (constrained to a maximum of 4).
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VolumetricCloud.ShadowMap.SpatialFiltering is to control the spatial filtering of volumetric cloud shadow maps in Unreal Engine 5’s rendering system. This setting variable is used to enable or disable the shadow map dilation/smoothing spatial filter and to specify the number of blur iterations.
This setting variable is primarily used in the Unreal Engine’s rendering system, specifically in the volumetric cloud rendering module. It is referenced in the VolumetricCloudRendering.cpp file, which is part of the Renderer module.
The value of this variable is set through a console variable (CVar) system, which allows for runtime configuration. It is initialized with a default value of 1, meaning the spatial filtering is enabled by default with one blur iteration.
The associated variable CVarVolumetricCloudShadowSpatialFiltering interacts directly with this setting. It is used to retrieve the value of the setting in the C++ code.
Developers must be aware that:
- The value represents the number of blur iterations for the spatial filter.
- It is clamped between 0 and 4, where 0 disables the filter, and 1-4 determines the number of blur iterations.
- This setting affects the visual quality and performance of volumetric cloud shadows.
Best practices when using this variable include:
- Experiment with different values to find the best balance between visual quality and performance for your specific use case.
- Consider exposing this setting to end-users for performance scaling on different hardware.
- Be mindful of the performance impact when increasing the number of blur iterations.
Regarding the associated variable CVarVolumetricCloudShadowSpatialFiltering:
- Its purpose is to provide programmatic access to the r.VolumetricCloud.ShadowMap.SpatialFiltering setting.
- It is used within the rendering system to determine if and how much spatial filtering should be applied to volumetric cloud shadows.
- The value is retrieved using the GetValueOnAnyThread() method, which suggests it can be accessed from multiple threads.
- Developers should use this variable when they need to read the current value of the spatial filtering setting in their C++ code.
- Best practice is to use the FMath::Clamp function when reading this value to ensure it stays within the valid range of 0 to 4.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:163
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowSpatialFiltering(
TEXT("r.VolumetricCloud.ShadowMap.SpatialFiltering"), 1,
TEXT("Enable/disable the shadow map dilation/smoothing spatial filter. Enabled when greater than 0 and it represents the number of blur iterations (constrained to a maximum of 4)."),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarVolumetricCloudShadowTemporalFilteringNewFrameWeight(
TEXT("r.VolumetricCloud.ShadowMap.TemporalFiltering.NewFrameWeight"), 1.0f,
TEXT("Experimental and needs more work so disabled by default. Value between [0.0, 1.0] representing the weight of current frame's contribution. Low values can cause precision issues resulting in depth not converging over time. Disabled when set to 1."),
#Associated Variable and Callsites
This variable is associated with another variable named CVarVolumetricCloudShadowSpatialFiltering
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:162
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowSpatialFiltering(
TEXT("r.VolumetricCloud.ShadowMap.SpatialFiltering"), 1,
TEXT("Enable/disable the shadow map dilation/smoothing spatial filter. Enabled when greater than 0 and it represents the number of blur iterations (constrained to a maximum of 4)."),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarVolumetricCloudShadowTemporalFilteringNewFrameWeight(
TEXT("r.VolumetricCloud.ShadowMap.TemporalFiltering.NewFrameWeight"), 1.0f,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:1903
Scope (from outer to inner):
file
lambda-function
Source code excerpt:
if (ShouldRenderCloudShadowmap(AtmosphericLight))
{
const int32 CloudShadowSpatialFiltering = FMath::Clamp(CVarVolumetricCloudShadowSpatialFiltering.GetValueOnAnyThread(), 0, 4);
const uint32 Resolution1D = GetVolumetricCloudShadowMapResolution(AtmosphericLight);
const FIntPoint Resolution2D = FIntPoint(Resolution1D, Resolution1D);
const FIntPoint TracingResolution2D = CloudShadowTemporalEnabled ? FIntPoint(Resolution1D>>1, Resolution1D>>1) : FIntPoint(Resolution1D, Resolution1D);
const EPixelFormat CloudShadowPixelFormat = PF_FloatR11G11B10;
if (ViewInfo.ViewState)