r.Water.SingleLayer.VSMFiltering

r.Water.SingleLayer.VSMFiltering

#Overview

name: r.Water.SingleLayer.VSMFiltering

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Water.SingleLayer.VSMFiltering is to control the use of virtual shadow map (VSM) filtering for single-layer water rendering in Unreal Engine 5. This setting is specifically related to the rendering system, particularly for water effects.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically in the single-layer water rendering subsystem. It’s referenced in the SingleLayerWaterRendering.cpp file, which is part of the core rendering functionality.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0, which means VSM filtering is disabled by default. Users can change this value at runtime using console commands or through engine configuration files.

The associated variable CVarWaterSingleLayerVSMFiltering directly interacts with r.Water.SingleLayer.VSMFiltering. They share the same value and purpose.

Developers must be aware that this variable only takes effect when using deferred rendering and when virtual shadow maps are supported and enabled. It’s also marked as render thread safe and as a scalability option, meaning it can be adjusted based on performance needs.

Best practices when using this variable include:

  1. Only enable it when using deferred rendering and virtual shadow maps.
  2. Consider the performance impact, as VSM filtering can be computationally expensive.
  3. Use it in conjunction with other water rendering settings for optimal visual quality.
  4. Test thoroughly on target hardware to ensure acceptable performance.

Regarding the associated variable CVarWaterSingleLayerVSMFiltering:

The purpose of CVarWaterSingleLayerVSMFiltering is identical to r.Water.SingleLayer.VSMFiltering. It’s the actual console variable implementation that controls the VSM filtering for single-layer water.

This variable is used in the Renderer module, specifically in the single-layer water rendering system. It’s defined and used in the SingleLayerWaterRendering.cpp file.

The value of CVarWaterSingleLayerVSMFiltering is set through the console variable system. It can be changed at runtime using console commands or through configuration files.

CVarWaterSingleLayerVSMFiltering directly interacts with the r.Water.SingleLayer.VSMFiltering setting. They are essentially the same thing, with CVarWaterSingleLayerVSMFiltering being the actual implementation.

Developers should be aware that this variable is checked in the IsWaterVirtualShadowMapFilteringEnabled_Runtime function, which determines whether VSM filtering should be applied to water rendering.

Best practices for using CVarWaterSingleLayerVSMFiltering are the same as for r.Water.SingleLayer.VSMFiltering. Developers should consider performance implications and ensure that the necessary rendering features (deferred rendering, virtual shadow maps) are enabled for this setting to have an effect.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SingleLayerWaterRendering.cpp:89

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarWaterSingleLayerVSMFiltering(
	TEXT("r.Water.SingleLayer.VSMFiltering"), 0,
	TEXT("When using deferred, virtual shadow map filtering is supported on single layer water. This cvar can be used to toggle it on/off at runtime."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

//
// Misc

#Associated Variable and Callsites

This variable is associated with another variable named CVarWaterSingleLayerVSMFiltering. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SingleLayerWaterRendering.cpp:88

Scope: file

Source code excerpt:

	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarWaterSingleLayerVSMFiltering(
	TEXT("r.Water.SingleLayer.VSMFiltering"), 0,
	TEXT("When using deferred, virtual shadow map filtering is supported on single layer water. This cvar can be used to toggle it on/off at runtime."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

//
// Misc

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SingleLayerWaterRendering.cpp:236

Scope (from outer to inner):

file
function     bool IsWaterVirtualShadowMapFilteringEnabled_Runtime

Source code excerpt:

bool IsWaterVirtualShadowMapFilteringEnabled_Runtime(const FStaticShaderPlatform Platform)
{
	return IsWaterVirtualShadowMapFilteringEnabled(Platform) && UseVirtualShadowMaps(Platform, GetMaxSupportedFeatureLevel(Platform)) && CVarWaterSingleLayerVSMFiltering.GetValueOnRenderThread() > 0;
}

bool NeedsSeparatedMainDirectionalLightTexture(const FStaticShaderPlatform Platform)
{
	return IsWaterDistanceFieldShadowEnabled(Platform) || IsWaterVirtualShadowMapFilteringEnabled(Platform);
}