r.HeterogeneousVolumes.Shadows.DebugTweak

r.HeterogeneousVolumes.Shadows.DebugTweak

#Overview

name: r.HeterogeneousVolumes.Shadows.DebugTweak

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.HeterogeneousVolumes.Shadows.DebugTweak is to provide a debug tweak value for the heterogeneous volumes shadow rendering system in Unreal Engine 5. This setting variable is specifically used for debugging and fine-tuning the shadow rendering for heterogeneous volumes.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the heterogeneous volumes rendering subsystem. Based on the callsites, it’s clear that this variable is utilized in both the voxel grid pipeline and the live shading pipeline for heterogeneous volumes.

The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with an initial value of 0, which can be changed at runtime through console commands or programmatically.

The associated variable CVarHeterogeneousVolumesShadowDebugTweak interacts directly with r.HeterogeneousVolumes.Shadows.DebugTweak. They share the same value, and CVarHeterogeneousVolumesShadowDebugTweak is used to access the value in the C++ code.

Developers must be aware that this variable is intended for debugging purposes only. It should not be relied upon for production-ready features or gameplay mechanics. The variable is marked as ECVF_RenderThreadSafe, meaning it’s safe to access from the render thread.

Best practices when using this variable include:

  1. Use it only during development and debugging phases.
  2. Reset it to 0 before building for release.
  3. Document any specific debug tweaks that proved useful during development.
  4. Be cautious about performance impacts when adjusting this value, as it may affect rendering performance.

Regarding the associated variable CVarHeterogeneousVolumesShadowDebugTweak:

The purpose of CVarHeterogeneousVolumesShadowDebugTweak is to provide programmatic access to the debug tweak value within the C++ code of the renderer.

This variable is used in the Renderer module, specifically in the heterogeneous volumes rendering system. It’s accessed in both the voxel grid pipeline and the live shading pipeline for shadow rendering.

The value of CVarHeterogeneousVolumesShadowDebugTweak is set by the console variable system and can be accessed using the GetValueOnRenderThread() method.

It interacts directly with r.HeterogeneousVolumes.Shadows.DebugTweak, sharing the same value.

Developers should be aware that this variable is used to pass the debug tweak value to shader parameters. In some cases, it might be intentionally set to 0 to disable the debug tweak.

Best practices for using CVarHeterogeneousVolumesShadowDebugTweak include:

  1. Access it only from the render thread using GetValueOnRenderThread().
  2. Consider the performance implications of frequently accessing this value.
  3. Use it consistently across the codebase when debugging heterogeneous volume shadows.
  4. Be prepared to remove or disable any code relying on this variable for release builds.

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

Scope: file

Source code excerpt:


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

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesShadowShadingRate(

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
function     bool RenderVolumetricShadowMapForLightForHeterogeneousVolumeWithLiveShading

Source code excerpt:

		// Dispatch data
		PassParameters->GroupCount = GroupCount;
		//PassParameters->ShadowDebugTweak = CVarHeterogeneousVolumesShadowDebugTweak.GetValueOnRenderThread();
		PassParameters->ShadowDebugTweak = 0;

		// Output
		PassParameters->RWVolumetricShadowLinkedListAllocatorBuffer = GraphBuilder.CreateUAV(VolumetricShadowLinkedListAllocatorBuffer, PF_R32_UINT);
		PassParameters->RWVolumetricShadowLinkedListBuffer = GraphBuilder.CreateUAV(VolumetricShadowLinkedListBuffer);
		PassParameters->RWBeerShadowMapTexture = GraphBuilder.CreateUAV(BeerShadowMapTexture);

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

Scope: file

Source code excerpt:

);

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

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

Scope (from outer to inner):

file
function     void RenderVolumetricShadowMapForLightWithVoxelGrid

Source code excerpt:

		// Dispatch data
		PassParameters->GroupCount = GroupCount;
		PassParameters->ShadowDebugTweak = CVarHeterogeneousVolumesShadowDebugTweak.GetValueOnRenderThread();

		// Output
		PassParameters->RWVolumetricShadowLinkedListAllocatorBuffer = GraphBuilder.CreateUAV(VolumetricShadowLinkedListAllocatorBuffer, PF_R32_UINT);
		PassParameters->RWVolumetricShadowLinkedListBuffer = GraphBuilder.CreateUAV(VolumetricShadowLinkedListBuffer);
		PassParameters->RWBeerShadowMapTexture = GraphBuilder.CreateUAV(BeerShadowMapTexture);
		PassParameters->RWDebugBuffer = GraphBuilder.CreateUAV(DebugBuffer);