r.PathTracing.MaxBounces
r.PathTracing.MaxBounces
#Overview
name: r.PathTracing.MaxBounces
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Sets the maximum number of path tracing bounces (default = -1 (driven by postprocesing volume))
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:
- A value of -1 means the setting will defer to the post-processing volume’s PathTracingMaxBounces value.
- 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:
- Consider the performance implications when increasing the number of bounces.
- Use the post-processing volume to control this setting dynamically in different areas of your game or application.
- 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:
- Its purpose is to provide programmatic access to the r.PathTracing.MaxBounces setting within the engine’s C++ code.
- It is used in the Renderer module to retrieve the current maximum bounces value during path tracing calculations.
- The value is set automatically based on the r.PathTracing.MaxBounces console variable.
- It interacts with the post-processing volume settings when its value is -1.
- Developers should be aware that modifying this variable directly in code will override the console variable setting.
- Best practice is to use this variable for reading the current value rather than modifying it directly, unless there’s a specific need for programmatic control over the maximum bounces.
#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;