r.PathTracing.MaxPathIntensity

r.PathTracing.MaxPathIntensity

#Overview

name: r.PathTracing.MaxPathIntensity

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.MaxPathIntensity is to control the clamping of light path intensities in the path tracing rendering system of Unreal Engine 5. It is used to prevent fireflies, which are bright specks that can appear in rendered images due to high-intensity light paths.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically within the path tracing subsystem. Based on the callsites, it’s clear that this variable is integral to the path tracing rendering process.

The value of this variable is set through a console variable (CVar) system. It can be modified at runtime using console commands or through configuration files. By default, it’s set to -1, which means it’s driven by the post-processing volume settings.

The associated variable CVarPathTracingMaxPathIntensity interacts directly with r.PathTracing.MaxPathIntensity. They share the same value and purpose.

Developers must be aware that:

  1. When this value is positive, it clamps light paths that exceed the specified intensity.
  2. When the value is -1 or negative, the clamping is controlled by the post-processing volume settings.
  3. This setting can significantly affect the visual quality of the rendered image, especially in scenes with high dynamic range lighting.

Best practices when using this variable include:

  1. Start with the default value (-1) and adjust only if fireflies are a problem in your specific scene.
  2. If adjusting, incrementally increase the value from 0 until fireflies are reduced without overly dampening the scene’s lighting dynamics.
  3. Consider scene-specific adjustments, as different environments may require different clamping values.
  4. Be aware of the interaction with post-processing volume settings when the value is negative.

Regarding the associated variable CVarPathTracingMaxPathIntensity: This is the actual console variable that controls the r.PathTracing.MaxPathIntensity setting. It’s defined in the path tracing rendering code and is used to retrieve the current value of the setting at runtime. The variable is marked as render thread safe, meaning it can be safely accessed and modified from the render thread without causing synchronization issues.

When working with CVarPathTracingMaxPathIntensity, developers should:

  1. Use the GetValueOnRenderThread() method to access its value safely within render thread code.
  2. Be aware that changes to this variable will immediately affect the path tracing rendering process.
  3. Consider exposing this setting in user-facing graphics options if fine-tuning of path tracing is desired in the final product.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


TAutoConsoleVariable<float> CVarPathTracingMaxPathIntensity(
	TEXT("r.PathTracing.MaxPathIntensity"),
	-1,
	TEXT("When positive, light paths greater that this amount are clamped to prevent fireflies (default = -1 (driven by postprocesing volume))"),
	ECVF_RenderThreadSafe
);

TAutoConsoleVariable<int32> CVarPathTracingApproximateCaustics(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:



TAutoConsoleVariable<float> CVarPathTracingMaxPathIntensity(
	TEXT("r.PathTracing.MaxPathIntensity"),
	-1,
	TEXT("When positive, light paths greater that this amount are clamped to prevent fireflies (default = -1 (driven by postprocesing volume))"),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
function     static void PreparePathTracingData

Source code excerpt:

	PathTracingData.MISMode = CVarPathTracingMISMode.GetValueOnRenderThread();
	PathTracingData.VolumeMISMode = CVarPathTracingVolumeMISMode.GetValueOnRenderThread();
	PathTracingData.MaxPathIntensity = CVarPathTracingMaxPathIntensity.GetValueOnRenderThread();
	if (PathTracingData.MaxPathIntensity <= 0)
	{
		// cvar clamp disabled, use PPV exposure value instad
		PathTracingData.MaxPathIntensity = FMath::Pow(2.0f, PPV.PathTracingMaxPathExposure);
	}
	PathTracingData.ApproximateCaustics = CVarPathTracingApproximateCaustics.GetValueOnRenderThread();