r.ManyLights.WorldSpaceTraces

r.ManyLights.WorldSpaceTraces

#Overview

name: r.ManyLights.WorldSpaceTraces

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.ManyLights.WorldSpaceTraces is to control whether world space shadow rays are traced for samples in the many lights rendering system. This setting is primarily used for debugging purposes in the ray tracing component of the many lights system.

This setting variable is primarily used in the rendering subsystem of Unreal Engine 5, specifically in the many lights module. It is referenced in the ManyLightsRayTracing.cpp file, which is part of the Renderer module.

The value of this variable is set through a console variable (CVarManyLightsWorldSpaceTraces) with a default value of 1 (enabled). It can be changed at runtime through console commands or programmatically.

This variable interacts closely with other ray tracing and many lights system variables, such as CVarManyLightsHardwareRayTracing. It is used in conjunction with these variables to determine the specific ray tracing behavior in the many lights system.

Developers should be aware that this variable is primarily intended for debugging purposes. Enabling world space traces may have performance implications, so it should be used judiciously in production environments.

Best practices for using this variable include:

  1. Use it primarily during development and debugging phases.
  2. Be mindful of potential performance impacts when enabled.
  3. Consider disabling it in release builds or performance-critical scenarios.

Regarding the associated variable CVarManyLightsWorldSpaceTraces:

The purpose of CVarManyLightsWorldSpaceTraces is to provide a programmatic interface to control the r.ManyLights.WorldSpaceTraces setting. It is an instance of TAutoConsoleVariable, which allows for runtime modification of the setting.

This variable is used directly in the Renderer module, specifically in the ManyLights namespace and related functions. It’s typically accessed using the GetValueOnRenderThread() method to retrieve its current value.

The value of CVarManyLightsWorldSpaceTraces is set when the variable is initialized, but can be changed at runtime through console commands or programmatically.

CVarManyLightsWorldSpaceTraces interacts directly with the rendering logic in the many lights system. It’s used in functions like IsUsingGlobalSDF() to determine rendering behavior.

Developers should be aware that changes to this variable will immediately affect the ray tracing behavior in the many lights system. It’s important to consider the performance implications of enabling this feature, especially in performance-sensitive scenarios.

Best practices for using CVarManyLightsWorldSpaceTraces include:

  1. Use it for fine-tuning and debugging the many lights system.
  2. Be cautious when modifying its value in shipping builds.
  3. Consider exposing it as a configurable option for advanced users or developers, but not for end-users in most cases.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarManyLightsWorldSpaceTraces(
	TEXT("r.ManyLights.WorldSpaceTraces"),
	1,
	TEXT("Whether to trace world space shadow rays for samples. Useful for debugging."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarManyLightsHardwareRayTracing(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarManyLightsWorldSpaceTraces(
	TEXT("r.ManyLights.WorldSpaceTraces"),
	1,
	TEXT("Whether to trace world space shadow rays for samples. Useful for debugging."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
namespace    ManyLights
function     bool IsUsingGlobalSDF

Source code excerpt:

	bool IsUsingGlobalSDF()
	{
		return IsEnabled() && CVarManyLightsWorldSpaceTraces.GetValueOnRenderThread() != 0 && !UseHardwareRayTracing();
	}

	BEGIN_SHADER_PARAMETER_STRUCT(FHairVoxelTraceParameters, )
		SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FHairStrandsViewUniformParameters, HairStrands)
		SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FVirtualVoxelParameters, VirtualVoxel)
	END_SHADER_PARAMETER_STRUCT()

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

Scope (from outer to inner):

file
function     void ManyLights::RayTraceLightSamples

Source code excerpt:

	}

	if (CVarManyLightsWorldSpaceTraces.GetValueOnRenderThread() != 0)
	{
		FCompactedTraceParameters CompactedTraceParameters = ManyLights::CompactManyLightsTraces(
			View,
			GraphBuilder,
			SampleBufferSize,
			LightSamples,