r.PathTracing.TemporalDenoiser.SubPixelOffset.StartMip

r.PathTracing.TemporalDenoiser.SubPixelOffset.StartMip

#Overview

name: r.PathTracing.TemporalDenoiser.SubPixelOffset.StartMip

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.PathTracing.TemporalDenoiser.SubPixelOffset.StartMip is to control the mip level at which subpixel offset is applied in the path tracing temporal denoiser. This setting variable is part of Unreal Engine 5’s rendering system, specifically for the path tracing feature.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, particularly in the path tracing and denoising subsystem. Based on the callsites, it’s clear that this variable is crucial for the spatial-temporal denoising process in path tracing.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 8, but can be changed at runtime through console commands or programmatically.

This variable interacts closely with other path tracing and denoising-related variables, such as CVarPathTracingTemporalDenoiserMotionOperation and CVarPathTracingTemporalDenoiserEnableSubPixelOffset. These variables work together to determine when and how subpixel offset is applied in the denoising process.

Developers should be aware that this variable affects the quality and performance of the path tracing denoiser. A higher value means subpixel offset will be applied to more mip levels, potentially improving quality but at the cost of performance.

Best practices when using this variable include:

  1. Experimenting with different values to find the optimal balance between image quality and performance for your specific use case.
  2. Considering the interaction with other related variables, especially CVarPathTracingTemporalDenoiserEnableSubPixelOffset.
  3. Being cautious about changing this value at runtime, as it could cause visual discontinuities.

Regarding the associated variable CVarPathTracingTemporalDenoiserSubPixelOffsetStartMip:

This is the actual CVar object that stores and manages the r.PathTracing.TemporalDenoiser.SubPixelOffset.StartMip setting. It’s used internally by the engine to access and modify the setting value.

The purpose of this variable is to provide a programmatic interface for the engine to interact with the setting. It’s used in functions like ShouldRemoveSelfSubpixelOffset and ShouldEnableSubpixelOffset to determine the behavior of the subpixel offset feature in the denoising process.

This variable is typically set at engine initialization but can be modified at runtime. It’s important for developers to use the appropriate methods (like GetValueOnRenderThread()) when accessing this variable to ensure thread-safety in rendering code.

Best practices for using this variable include:

  1. Always accessing it using the appropriate thread-safe methods in rendering code.
  2. Considering caching its value if it’s accessed frequently in performance-critical sections.
  3. Being aware that changes to this variable will affect the rendering pipeline, so it should be modified carefully.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:193

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserSubPixelOffsetStartMip(
		TEXT("r.PathTracing.TemporalDenoiser.SubPixelOffset.StartMip"),
		8,
		TEXT("From 0 to this mip, we will perform subpixel offset"),
		ECVF_RenderThreadSafe
	);

	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserMotionOperation(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:192

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	);

	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserSubPixelOffsetStartMip(
		TEXT("r.PathTracing.TemporalDenoiser.SubPixelOffset.StartMip"),
		8,
		TEXT("From 0 to this mip, we will perform subpixel offset"),
		ECVF_RenderThreadSafe
	);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:426

Scope (from outer to inner):

file
function     static bool ShouldRemoveSelfSubpixelOffset

Source code excerpt:

{
	bool bRemoveSelfSubpixelOffset = CVarPathTracingTemporalDenoiserMotionOperation.GetValueOnRenderThread() == 1 
		&& MipLevel <= CVarPathTracingTemporalDenoiserSubPixelOffsetStartMip.GetValueOnRenderThread()
		&& CVarPathTracingTemporalDenoiserEnableSubPixelOffset.GetValueOnAnyThread() != 0;

	return bRemoveSelfSubpixelOffset;
}

static float GetErrorDistanceBasedOnDeltaE(float DeltaE)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:506

Scope (from outer to inner):

file
function     static bool ShouldEnableSubpixelOffset

Source code excerpt:

static bool ShouldEnableSubpixelOffset(uint32 MipLevel)
{
	uint32 PixelOffsetStartMip = CVarPathTracingTemporalDenoiserSubPixelOffsetStartMip.GetValueOnRenderThread();
	bool bShouldEnableSubpixelOffset = (MipLevel <= PixelOffsetStartMip) &&
		CVarPathTracingTemporalDenoiserEnableSubPixelOffset.GetValueOnAnyThread() != 0;

	return bShouldEnableSubpixelOffset;
}