r.PathTracing.FrameIndependentTemporalSeed

r.PathTracing.FrameIndependentTemporalSeed

#Overview

name: r.PathTracing.FrameIndependentTemporalSeed

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.FrameIndependentTemporalSeed is to control the temporal seed behavior in path tracing for rendering. It determines whether different temporal seeds are used for each sample across frames or if the sequence is reset at the start of each frame.

This setting variable is primarily used in the rendering system, specifically within the path tracing subsystem of Unreal Engine 5. Based on the callsites, it is utilized in the Renderer module, as evidenced by its implementation in the PathTracing.cpp file.

The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 1 (on) and can be changed at runtime using console commands or through engine configuration files.

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

Developers must be aware that this variable affects the consistency of path tracing results across frames. When enabled (set to 1), it produces different temporal seeds for each sample across frames, which can lead to more varied results but may introduce some temporal instability. When disabled (set to 0), it resets the sequence at the start of each frame, potentially providing more consistent results but possibly at the cost of some visual diversity.

Best practices when using this variable include:

  1. Consider the trade-off between temporal stability and visual variety in your specific use case.
  2. Test both settings (0 and 1) to determine which provides the best visual results for your scene.
  3. Be aware that changing this setting may affect the convergence rate of path tracing, especially in static scenes.
  4. If using it in conjunction with other path tracing settings, ensure they work well together for your desired outcome.

Regarding the associated variable CVarPathTracingFrameIndependentTemporalSeed:

This is the actual console variable that controls the behavior described for r.PathTracing.FrameIndependentTemporalSeed. It is used internally by the engine to retrieve and apply the setting value. The variable is of type TAutoConsoleVariable, which allows it to be easily modified at runtime.

The value of CVarPathTracingFrameIndependentTemporalSeed is accessed in the rendering code using the GetValueOnRenderThread() method, ensuring thread-safe access to the current setting. This value is then used to configure the path tracing system, specifically setting the LockedSamplingPattern flag in the path tracing configuration.

Developers should be aware that changes to this variable will take effect on the render thread, which may not be immediately visible in the next frame due to potential buffering or asynchronous rendering processes. When making changes to this variable, it’s important to allow for a few frames to pass before evaluating the visual impact.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarPathTracingFrameIndependentTemporalSeed(
	TEXT("r.PathTracing.FrameIndependentTemporalSeed"),
	1,
	TEXT("Indicates to use different temporal seed for each sample across frames rather than resetting the sequence at the start of each frame\n")
	TEXT("0: off\n")
	TEXT("1: on (default)\n"),
	ECVF_RenderThreadSafe
);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

TAutoConsoleVariable<int32> CVarPathTracingFrameIndependentTemporalSeed(
	TEXT("r.PathTracing.FrameIndependentTemporalSeed"),
	1,
	TEXT("Indicates to use different temporal seed for each sample across frames rather than resetting the sequence at the start of each frame\n")
	TEXT("0: off\n")
	TEXT("1: on (default)\n"),
	ECVF_RenderThreadSafe

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

Scope: file

Source code excerpt:

	const bool bUseExperimental = CVarPathTracingExperimental.GetValueOnRenderThread() != 0;

	Config.LockedSamplingPattern = CVarPathTracingFrameIndependentTemporalSeed.GetValueOnRenderThread() == 0;
	Config.UseCameraMediumTracking = CVarPathTracingCameraMediumTracking.GetValueOnRenderThread() != 0;
	Config.UseAdaptiveSampling = bUseExperimental && CVarPathTracingAdaptiveSampling.GetValueOnAnyThread() != 0;
	Config.AdaptiveSamplingThreshold = CVarPathTracingAdaptiveSamplingErrorThreshold.GetValueOnRenderThread();

	// compute an integer code of what show flags and booleans related to lights are currently enabled so we can detect changes
	Config.LightShowFlags = 0;