r.HeterogeneousVolumes.Shadows.ShadingRate

r.HeterogeneousVolumes.Shadows.ShadingRate

#Overview

name: r.HeterogeneousVolumes.Shadows.ShadingRate

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.ShadingRate is to control the shading rate for shadows in heterogeneous volumes rendering. This setting variable is part of Unreal Engine’s rendering system, specifically for the heterogeneous volumes feature.

This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the heterogeneous volumes subsystem. Based on the callsites, it’s clear that this variable is used within the HeterogeneousVolumesVoxelGridPipeline.cpp file, which suggests it’s part of the voxel grid pipeline for heterogeneous volumes.

The value of this variable is set as a console variable (CVar) with a default value of 2. It can be modified at runtime through the console or configuration files.

The associated variable CVarHeterogeneousVolumesShadowShadingRate interacts directly with this setting. It’s used to retrieve the value of the setting in the GetShadingRateForShadows() function.

Developers should be aware that this variable affects the performance and quality of shadow rendering in heterogeneous volumes. A higher value might improve performance at the cost of shadow quality, while a lower value might increase shadow quality but potentially impact performance.

Best practices when using this variable include:

  1. Experimenting with different values to find the right balance between performance and visual quality for your specific use case.
  2. Considering the target hardware when setting this value, as lower-end devices might benefit from a higher shading rate (lower quality) for better performance.
  3. Using this in conjunction with other heterogeneous volumes settings for optimal results.
  4. Monitoring performance metrics when adjusting this value to ensure it’s not negatively impacting frame rates.

Regarding the associated variable CVarHeterogeneousVolumesShadowShadingRate:

The purpose of CVarHeterogeneousVolumesShadowShadingRate is to provide a programmatic interface to access and modify the r.HeterogeneousVolumes.Shadows.ShadingRate setting.

This variable is used within the Renderer module, specifically in the heterogeneous volumes subsystem. It’s defined and used in the HeterogeneousVolumesVoxelGridPipeline.cpp file.

The value of this variable is set when the r.HeterogeneousVolumes.Shadows.ShadingRate console variable is initialized. It’s accessed using the GetValueOnRenderThread() method.

This variable interacts directly with the r.HeterogeneousVolumes.Shadows.ShadingRate setting, essentially serving as its C++ representation within the engine code.

Developers should be aware that changes to this variable will directly affect the shadow shading rate for heterogeneous volumes. It’s used in the GetShadingRateForShadows() function, which suggests it’s a critical part of the shadow rendering pipeline for heterogeneous volumes.

Best practices for using this variable include:

  1. Accessing it only from the render thread to ensure thread safety.
  2. Using the provided GetValueOnRenderThread() method to retrieve its value, rather than accessing it directly.
  3. Considering caching its value if it’s accessed frequently, to avoid potential performance overhead from repeated console variable lookups.
  4. Being cautious when modifying its value directly, as it could lead to inconsistencies with the console variable setting.

#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:253

Scope: file

Source code excerpt:


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

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesShadowOutOfFrustumShadingRate(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

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

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

Scope (from outer to inner):

file
namespace    HeterogeneousVolumes
function     float GetShadingRateForShadows

Source code excerpt:

	float GetShadingRateForShadows()
	{
		return FMath::Max(CVarHeterogeneousVolumesShadowShadingRate.GetValueOnRenderThread(), 0.1);
	}

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