r.RayTracing.ForceAllRayTracingEffects

r.RayTracing.ForceAllRayTracingEffects

#Overview

name: r.RayTracing.ForceAllRayTracingEffects

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.RayTracing.ForceAllRayTracingEffects is to control the global state of ray tracing effects in the rendering system of Unreal Engine 5. It allows developers to forcibly enable or disable all ray tracing effects throughout the engine.

This setting variable is primarily used by the rendering system, specifically within the deferred shading renderer module. Based on the callsites, it’s clear that the DeferredShadingRenderer.cpp file in the Renderer module relies on this variable.

The value of this variable is set through a console variable (CVarForceAllRayTracingEffects) which is initialized with the default value of GForceAllRayTracingEffects (-1). This allows the value to be changed at runtime through console commands.

The associated variable CVarForceAllRayTracingEffects interacts directly with r.RayTracing.ForceAllRayTracingEffects. It’s a TAutoConsoleVariable that wraps the actual setting and provides runtime access and modification capabilities.

Developers must be aware that this variable has three possible states:

  1. -1: Default state, does not force any change to ray tracing effects.
  2. 0: Forcibly disables all ray tracing effects.
  3. 1: Forcibly enables all ray tracing effects.

The best practices when using this variable include:

  1. Use it primarily for debugging or testing purposes, not for production builds.
  2. Be cautious when enabling all ray tracing effects as it may significantly impact performance on less capable hardware.
  3. Remember to reset it to -1 (default) after testing to allow individual ray tracing effects to be controlled separately.

Regarding the associated variable CVarForceAllRayTracingEffects: The purpose of CVarForceAllRayTracingEffects is to provide a console-accessible interface for the r.RayTracing.ForceAllRayTracingEffects setting. It allows for runtime modification of the ray tracing effects state.

This console variable is used in the rendering system, specifically in the ShouldRenderRayTracingEffect function within the DeferredShadingRenderer.cpp file.

The value of CVarForceAllRayTracingEffects is initially set to GForceAllRayTracingEffects (-1) but can be changed at runtime through console commands.

CVarForceAllRayTracingEffects directly interacts with r.RayTracing.ForceAllRayTracingEffects, essentially serving as its runtime-accessible counterpart.

Developers should be aware that changes to CVarForceAllRayTracingEffects will immediately affect the global ray tracing state. It’s accessed on the render thread, so modifications should be thread-safe.

Best practices for using CVarForceAllRayTracingEffects include:

  1. Use GetValueOnRenderThread() when accessing its value in render-thread code.
  2. Be cautious about frequently changing this value, as it affects the entire rendering pipeline.
  3. Consider using this for quick toggling of ray tracing effects during development or for creating graphics options in games.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:167

Scope: file

Source code excerpt:

static int32 GForceAllRayTracingEffects = -1;
static TAutoConsoleVariable<int32> CVarForceAllRayTracingEffects(
	TEXT("r.RayTracing.ForceAllRayTracingEffects"),
	GForceAllRayTracingEffects,
	TEXT("Force all ray tracing effects ON/OFF.\n")
	TEXT(" -1: Do not force (default) \n")
	TEXT(" 0: All ray tracing effects disabled\n")
	TEXT(" 1: All ray tracing effects enabled"),
	ECVF_RenderThreadSafe);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:166

Scope: file

Source code excerpt:


static int32 GForceAllRayTracingEffects = -1;
static TAutoConsoleVariable<int32> CVarForceAllRayTracingEffects(
	TEXT("r.RayTracing.ForceAllRayTracingEffects"),
	GForceAllRayTracingEffects,
	TEXT("Force all ray tracing effects ON/OFF.\n")
	TEXT(" -1: Do not force (default) \n")
	TEXT(" 0: All ray tracing effects disabled\n")
	TEXT(" 1: All ray tracing effects enabled"),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:3492

Scope (from outer to inner):

file
function     bool ShouldRenderRayTracingEffect

Source code excerpt:

	}

	const int32 OverrideMode = CVarForceAllRayTracingEffects.GetValueOnRenderThread();

	if (OverrideMode >= 0)
	{
		return OverrideMode > 0;
	}
	else