r.Translucency.HeterogeneousVolumes

r.Translucency.HeterogeneousVolumes

#Overview

name: r.Translucency.HeterogeneousVolumes

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.Translucency.HeterogeneousVolumes is to enable or disable compositing with heterogeneous volumes when rendering translucency in Unreal Engine 5.

This setting variable is primarily used in the rendering system, specifically for handling translucency and heterogeneous volumes. Based on the callsites, it is primarily utilized in the Renderer module of Unreal Engine 5.

The value of this variable is set through a console variable (CVar) system. It is defined as a TAutoConsoleVariable with an initial value of 0, meaning it’s disabled by default.

The associated variable CVarTranslucencyHeterogeneousVolumes interacts directly with r.Translucency.HeterogeneousVolumes. They share the same value and purpose.

Developers must be aware that this variable is marked as ECVF_RenderThreadSafe and ECVF_ReadOnly. This means it’s safe to read from any thread, but it cannot be changed at runtime. Any changes to this variable will require a shader recompilation, as evidenced by its usage in the ShaderMapAppendKeyString function.

Best practices when using this variable include:

  1. Consider the performance implications of enabling heterogeneous volume compositing with translucency.
  2. Be aware that enabling this feature may impact shader compilation times and memory usage.
  3. Test thoroughly with this feature both enabled and disabled to ensure your game performs well in both scenarios.

Regarding the associated variable CVarTranslucencyHeterogeneousVolumes:

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarTranslucencyHeterogeneousVolumes(
	TEXT("r.Translucency.HeterogeneousVolumes"),
	0,
	TEXT("Enables composting with heterogeneous volumes when rendering translucency (Default = 0)\n"),
	ECVF_RenderThreadSafe | ECVF_ReadOnly
);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesComposition(

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/Shader.cpp:2306

Scope (from outer to inner):

file
function     void ShaderMapAppendKeyString

Source code excerpt:

		}

		static const auto CompTranslucencyCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Translucency.HeterogeneousVolumes"));
		if (CompTranslucencyCVar && CompTranslucencyCVar->GetValueOnAnyThread() != 0)
		{
			KeyString += TEXT("_HVCOMPTRANSL");
		}
	}

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarTranslucencyHeterogeneousVolumes(
	TEXT("r.Translucency.HeterogeneousVolumes"),
	0,
	TEXT("Enables composting with heterogeneous volumes when rendering translucency (Default = 0)\n"),
	ECVF_RenderThreadSafe | ECVF_ReadOnly
);

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

Scope (from outer to inner):

file
function     bool ShouldCompositeHeterogeneousVolumesWithTranslucency

Source code excerpt:

bool ShouldCompositeHeterogeneousVolumesWithTranslucency()
{
	return CVarTranslucencyHeterogeneousVolumes.GetValueOnAnyThread() != 0;
}

EHeterogeneousVolumesCompositionType GetHeterogeneousVolumesCompositionType()
{
	int32 CompositionOrder = CVarHeterogeneousVolumesComposition.GetValueOnRenderThread();
	switch (CompositionOrder)