r.PathTracing.MaxBounces

r.PathTracing.MaxBounces

#Overview

name: r.PathTracing.MaxBounces

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.PathTracing.MaxBounces is to control the maximum number of bounces in the path tracing rendering system of Unreal Engine 5. It is primarily used for the rendering subsystem, specifically for path tracing calculations.

This setting variable is relied upon by the Renderer module of Unreal Engine, as evidenced by its implementation in the PathTracing.cpp file within the Renderer’s private directory.

The value of this variable is set through a console variable (CVarPathTracingMaxBounces) with a default value of -1. This default value indicates that the actual maximum bounces will be driven by the post-processing volume settings unless explicitly set.

The associated variable CVarPathTracingMaxBounces interacts directly with r.PathTracing.MaxBounces, as they share the same value and purpose. This console variable is used to retrieve the current value of the setting in the rendering thread.

Developers must be aware that:

  1. A value of -1 means the setting will defer to the post-processing volume’s PathTracingMaxBounces value.
  2. This setting has a direct impact on rendering quality and performance, as higher values will result in more accurate lighting but increased render times.

Best practices when using this variable include:

  1. Consider the performance implications when increasing the number of bounces.
  2. Use the post-processing volume to control this setting dynamically in different areas of your game or application.
  3. Test thoroughly with different values to find the optimal balance between visual quality and performance for your specific use case.

Regarding the associated variable CVarPathTracingMaxBounces:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:77

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarPathTracingMaxBounces(
	TEXT("r.PathTracing.MaxBounces"),
	-1,
	TEXT("Sets the maximum number of path tracing bounces (default = -1 (driven by postprocesing volume))"),
	ECVF_RenderThreadSafe
);

TAutoConsoleVariable<int32> CVarPathTracingSamplesPerPixel(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:76

Scope: file

Source code excerpt:

);

TAutoConsoleVariable<int32> CVarPathTracingMaxBounces(
	TEXT("r.PathTracing.MaxBounces"),
	-1,
	TEXT("Sets the maximum number of path tracing bounces (default = -1 (driven by postprocesing volume))"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:616

Scope (from outer to inner):

file
function     static void PreparePathTracingData

Source code excerpt:

	const FEngineShowFlags& ShowFlags = View.Family->EngineShowFlags;

	int32 MaxBounces = CVarPathTracingMaxBounces.GetValueOnRenderThread();
	if (MaxBounces < 0)
	{
		MaxBounces = PPV.PathTracingMaxBounces;
	}

	PathTracingData.MaxBounces = MaxBounces;