r.ManyLights.HardwareRayTracing

r.ManyLights.HardwareRayTracing

#Overview

name: r.ManyLights.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.ManyLights.HardwareRayTracing is to control whether hardware ray tracing is used for shadow rays in the Many Lights rendering system of Unreal Engine 5.

This setting variable is primarily used in the rendering system, specifically in the Many Lights module, which is responsible for handling complex lighting scenarios with numerous light sources.

Based on the callsites, this variable is utilized in the Renderer module of Unreal Engine, particularly in the ManyLightsRayTracing.cpp file.

The value of this variable is set through the console variable system (CVarManyLightsHardwareRayTracing). It is initialized with a default value of 1, indicating that hardware ray tracing for shadow rays is enabled by default.

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

Developers must be aware that this variable is only effective when ray tracing is enabled in the engine. The UseHardwareRayTracing() function checks both if ray tracing is enabled and if this variable is set to a non-zero value.

Best practices when using this variable include:

  1. Ensure that the hardware supports ray tracing before enabling this feature.
  2. Consider the performance implications of enabling hardware ray tracing for shadow rays, especially in scenes with many lights.
  3. Use this in conjunction with other ray tracing settings for optimal results.

Regarding the associated variable CVarManyLightsHardwareRayTracing:

The purpose of CVarManyLightsHardwareRayTracing is to provide a programmatic interface to the r.ManyLights.HardwareRayTracing setting within the engine’s code.

This console variable is used in the Renderer module, specifically in the Many Lights ray tracing system.

The value of this variable is set when the engine initializes its console variables, but it can be changed at runtime through console commands.

It interacts directly with the r.ManyLights.HardwareRayTracing setting, effectively controlling the same functionality.

Developers should be aware that this variable is marked with ECVF_Scalability and ECVF_RenderThreadSafe flags, indicating that it affects scalability settings and is safe to modify from the render thread.

Best practices for using this variable include:

  1. Access its value using GetValueOnRenderThread() when in render thread context.
  2. Consider exposing this setting in user-facing graphics options if fine-grained control over ray tracing is desired.
  3. Use in conjunction with IsRayTracingEnabled() checks to ensure proper functionality.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLightsRayTracing.cpp:42

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarManyLightsHardwareRayTracing(
	TEXT("r.ManyLights.HardwareRayTracing"),
	1,
	TEXT("Whether to use hardware ray tracing for shadow rays."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarManyLightsHardwareRayTracingInline(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLightsRayTracing.cpp:41

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarManyLightsHardwareRayTracing(
	TEXT("r.ManyLights.HardwareRayTracing"),
	1,
	TEXT("Whether to use hardware ray tracing for shadow rays."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLightsRayTracing.cpp:101

Scope (from outer to inner):

file
namespace    ManyLights
function     bool UseHardwareRayTracing

Source code excerpt:

		{
			return IsRayTracingEnabled() 
				&& CVarManyLightsHardwareRayTracing.GetValueOnRenderThread() != 0;
		}
		#else
		{
			return false;
		}
		#endif