r.HeterogeneousVolumes.HardwareRayTracing

r.HeterogeneousVolumes.HardwareRayTracing

#Overview

name: r.HeterogeneousVolumes.HardwareRayTracing

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.HardwareRayTracing is to enable or disable hardware ray tracing acceleration for heterogeneous volumes in Unreal Engine’s rendering system. This setting variable is specifically related to the rendering of complex volumetric effects using ray tracing technology.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the HeterogeneousVolumes subsystem. The code references are found in the file “HeterogeneousVolumes.cpp”, which suggests that this variable is crucial for the implementation of heterogeneous volume rendering.

The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 0, which means hardware ray tracing acceleration for heterogeneous volumes is disabled by default.

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

Developers must be aware that this variable is render thread safe (ECVF_RenderThreadSafe), meaning it can be safely modified from the render thread without causing race conditions or other threading issues.

Best practices when using this variable include:

  1. Only enable it when hardware ray tracing is supported and beneficial for the project.
  2. Consider the performance implications of enabling hardware ray tracing for heterogeneous volumes.
  3. Test thoroughly with both enabled and disabled states to ensure correct rendering in all scenarios.

Regarding the associated variable CVarHeterogeneousVolumesHardwareRayTracing:

The purpose of CVarHeterogeneousVolumesHardwareRayTracing is identical to r.HeterogeneousVolumes.HardwareRayTracing. It’s an internal representation of the console variable used within the C++ code.

This variable is used within the HeterogeneousVolumes namespace, specifically in the UseHardwareRayTracing() function. This function checks if ray tracing is enabled globally and if this specific variable is set to a non-zero value.

The value of this variable is set through the CVar system and can be modified at runtime.

It interacts directly with the IsRayTracingEnabled() function, suggesting that global ray tracing settings also influence the behavior of heterogeneous volume rendering.

Developers should be aware that this variable’s value is retrieved on the render thread (GetValueOnRenderThread()), which is important for thread-safety considerations.

Best practices include:

  1. Use the UseHardwareRayTracing() function to check if hardware ray tracing for heterogeneous volumes is enabled, rather than directly accessing the variable.
  2. Consider the interaction with global ray tracing settings when modifying or relying on this variable.
  3. Be mindful of the performance implications when enabling this feature, especially on less powerful hardware.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesHardwareRayTracing(
	TEXT("r.HeterogeneousVolumes.HardwareRayTracing"),
	0,
	TEXT("Enables hardware ray tracing acceleration (Default = 0)"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesIndirectLighting(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesHardwareRayTracing(
	TEXT("r.HeterogeneousVolumes.HardwareRayTracing"),
	0,
	TEXT("Enables hardware ray tracing acceleration (Default = 0)"),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
namespace    HeterogeneousVolumes
function     bool UseHardwareRayTracing

Source code excerpt:

	{
		return IsRayTracingEnabled()
			&& (CVarHeterogeneousVolumesHardwareRayTracing.GetValueOnRenderThread() != 0);
	}

	bool UseIndirectLighting()
	{
		return CVarHeterogeneousVolumesIndirectLighting.GetValueOnRenderThread() != 0;
	}