r.HeterogeneousVolumes.Shadows.OutOfFrustumShadingRate

r.HeterogeneousVolumes.Shadows.OutOfFrustumShadingRate

#Overview

name: r.HeterogeneousVolumes.Shadows.OutOfFrustumShadingRate

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.Shadows.OutOfFrustumShadingRate is to control the shading rate for out-of-frustum shadows in heterogeneous volumes rendering. This setting is part of Unreal Engine 5’s advanced rendering system, specifically targeting the handling of volumetric shadows.

This setting variable is primarily used by the Renderer module, particularly within the HeterogeneousVolumes namespace. It’s implemented in the HeterogeneousVolumesVoxelGridPipeline.cpp file, which suggests it’s part of the voxel-based rendering pipeline for heterogeneous volumes.

The value of this variable is set using a TAutoConsoleVariable, which means it can be adjusted at runtime through console commands. The default value is set to 2, but it can be changed dynamically.

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

Developers should be aware that this variable affects the performance and quality trade-off for rendering shadows in heterogeneous volumes, particularly for areas outside the main view frustum. A higher value may improve performance at the cost of shadow quality, while a lower value may enhance shadow quality but potentially impact performance.

Best practices when using this variable include:

  1. Experimenting with different values to find the optimal balance between performance and visual quality for your specific use case.
  2. Considering the target hardware capabilities when adjusting this value.
  3. Using it in conjunction with other shadow and volumetric rendering settings for a holistic approach to optimization.

Regarding the associated variable CVarHeterogeneousVolumesShadowOutOfFrustumShadingRate:

This is an internal representation of the r.HeterogeneousVolumes.Shadows.OutOfFrustumShadingRate console variable. It’s used within the C++ code to access and manipulate the setting value. The GetValueOnRenderThread() method is used to retrieve its current value safely in render thread contexts.

The GetOutOfFrustumShadingRateForShadows() function uses this variable to determine the shading rate, ensuring a minimum value of 0.1. This suggests that while the setting can be adjusted freely, the engine enforces a lower limit to maintain a baseline level of shadow quality.

Developers should note that changes to this variable will take effect on the render thread, which is important for understanding when modifications will be applied during runtime.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesShadowOutOfFrustumShadingRate(
	TEXT("r.HeterogeneousVolumes.Shadows.OutOfFrustumShadingRate"),
	2,
	TEXT("Debug tweak value (Default = 0)\n"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesShadowJitter(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesShadowOutOfFrustumShadingRate(
	TEXT("r.HeterogeneousVolumes.Shadows.OutOfFrustumShadingRate"),
	2,
	TEXT("Debug tweak value (Default = 0)\n"),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
namespace    HeterogeneousVolumes
function     float GetOutOfFrustumShadingRateForShadows

Source code excerpt:

	float GetOutOfFrustumShadingRateForShadows()
	{
		return FMath::Max(CVarHeterogeneousVolumesShadowOutOfFrustumShadingRate.GetValueOnRenderThread(), 0.1);
	}

	bool EnableJitterForShadows()
	{
		return CVarHeterogeneousVolumesShadowJitter.GetValueOnRenderThread() != 0;
	}