r.HeterogeneousVolumes.LightingCache.UseAVSM

r.HeterogeneousVolumes.LightingCache.UseAVSM

#Overview

name: r.HeterogeneousVolumes.LightingCache.UseAVSM

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.HeterogeneousVolumes.LightingCache.UseAVSM is to control the use of Adaptive Volumetric Shadow Maps (AVSMs) when evaluating self-shadowing in heterogeneous volumes rendering.

This setting variable is primarily used in the rendering system, specifically in the heterogeneous volumes subsystem of Unreal Engine 5. It is part of the Renderer module, as evidenced by its location in the HeterogeneousVolumes.cpp file within the Renderer’s Private directory.

The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 1, meaning AVSMs are enabled by default for self-shadowing evaluation.

This variable interacts closely with its associated variable CVarHeterogeneousVolumesLightingCacheUseAVSM. They share the same value and are used interchangeably in the code.

Developers should be aware that this variable affects the rendering performance and quality of heterogeneous volumes. Enabling AVSMs (value = 1) may provide better quality self-shadowing but could potentially impact performance.

Best practices when using this variable include:

  1. Testing the impact on performance and visual quality with and without AVSMs enabled.
  2. Considering the specific requirements of the project, balancing between rendering quality and performance.
  3. Being mindful of its interaction with other heterogeneous volumes settings.

Regarding the associated variable CVarHeterogeneousVolumesLightingCacheUseAVSM:

This is the actual console variable that controls the AVSM usage. It is defined as an integer with a default value of 1 (enabled). It is marked as render thread safe, meaning it can be safely accessed and modified from the render thread.

The variable is used in the UseAdaptiveVolumetricShadowMapForSelfShadowing function to determine whether AVSMs should be used for a specific primitive’s self-shadowing. This function considers not only the AVSM setting but also whether heterogeneous volumes should cast shadows at all and whether the specific primitive casts dynamic shadows.

Developers should be aware that changing this variable at runtime will affect the rendering of heterogeneous volumes immediately. They should also note that this setting works in conjunction with other shadow casting and primitive-specific settings to determine the final shadowing behavior.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumes.cpp:193

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesLightingCacheUseAVSM(
	TEXT("r.HeterogeneousVolumes.LightingCache.UseAVSM"),
	1,
	TEXT("Enables use of AVSMs when evaluating self-shadowing (Default = 1)"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesLightingCacheDownsampleFactor(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumes.cpp:192

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesLightingCacheUseAVSM(
	TEXT("r.HeterogeneousVolumes.LightingCache.UseAVSM"),
	1,
	TEXT("Enables use of AVSMs when evaluating self-shadowing (Default = 1)"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumes.cpp:455

Scope (from outer to inner):

file
namespace    HeterogeneousVolumes
function     bool UseAdaptiveVolumetricShadowMapForSelfShadowing

Source code excerpt:

	bool UseAdaptiveVolumetricShadowMapForSelfShadowing(const FPrimitiveSceneProxy* PrimitiveSceneProxy)
	{
		bool bUseAVSM = CVarHeterogeneousVolumesLightingCacheUseAVSM.GetValueOnRenderThread() != 0;
		bool bPrimitiveCastsDynamicShadows = PrimitiveSceneProxy->CastsDynamicShadow();
		return ShouldHeterogeneousVolumesCastShadows() && bUseAVSM && bPrimitiveCastsDynamicShadows;
	}

	bool UseLightingCacheForInscattering()
	{