r.ScreenPercentage.Default.PathTracer.Mode

r.ScreenPercentage.Default.PathTracer.Mode

#Overview

name: r.ScreenPercentage.Default.PathTracer.Mode

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.ScreenPercentage.Default.PathTracer.Mode is to control the default screen percentage mode for path tracing in Unreal Engine 5. This setting is part of the rendering system, specifically related to the path tracing feature.

This setting variable is primarily used in the Engine module, as evidenced by its declaration in the LegacyScreenPercentageDriver.cpp file. It’s part of the screen percentage system, which allows rendering at lower resolutions and upscaling for better performance.

The value of this variable is set using a console variable (CVar) system. It’s initialized with the default value of EScreenPercentageMode::Manual (which is likely an enum value of 0).

This variable interacts closely with other screen percentage-related variables, such as CVarScreenPercentage. It’s also associated with CVarScreenPercentageDefaultPathTracerMode, which appears to be the actual C++ variable holding the value.

Developers must be aware that this setting is specific to path tracing mode. It’s used when the ViewStatus is EViewStatusForScreenPercentage::PathTracer. The value is clamped between 0 and 2, suggesting there are likely three possible modes (probably corresponding to Manual, Spatial, and Temporal upscaling methods).

Best practices when using this variable include:

  1. Understanding the performance implications of different screen percentage modes in path tracing.
  2. Testing thoroughly with different modes to find the best balance between quality and performance for your specific use case.
  3. Being aware of how this setting interacts with other screen percentage and path tracing settings.

Regarding the associated variable CVarScreenPercentageDefaultPathTracerMode:

The purpose of CVarScreenPercentageDefaultPathTracerMode is to store the actual value of the r.ScreenPercentage.Default.PathTracer.Mode setting. It’s implemented as a TAutoConsoleVariable, which is Unreal Engine’s way of exposing settings that can be changed at runtime through the console.

This variable is used in the Engine module, specifically in the screen percentage system. It’s defined in the same file as the console command, indicating its close relationship with the command.

The value of this variable is set when the console command is used, and it’s retrieved using the GetValueOnGameThread() method.

This variable directly interacts with the r.ScreenPercentage.Default.PathTracer.Mode console command. It’s used to determine the screen percentage mode when in path tracing view status.

Developers should be aware that this variable is marked with ECVF_Scalability and ECVF_Default flags, indicating it’s a scalability setting that has a default value.

Best practices for using this variable include:

  1. Accessing its value using GetValueOnGameThread() when needed, rather than caching it, to ensure you always have the most up-to-date setting.
  2. Being aware of the performance implications of changing this value, especially in a shipping game.
  3. Consider exposing this setting in your game’s graphics options if path tracing is a significant feature in your game.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LegacyScreenPercentageDriver.cpp:28

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarScreenPercentageDefaultPathTracerMode(
	TEXT("r.ScreenPercentage.Default.PathTracer.Mode"), int32(EScreenPercentageMode::Manual),
	TEXT(""),
	ECVF_Scalability | ECVF_Default);

static TAutoConsoleVariable<float> CVarScreenPercentage(
	TEXT("r.ScreenPercentage"), 0.0f,
	TEXT("To render in lower resolution and upscale for better performance (combined up with the blenable post process setting).\n")

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LegacyScreenPercentageDriver.cpp:27

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_Default);

static TAutoConsoleVariable<int32> CVarScreenPercentageDefaultPathTracerMode(
	TEXT("r.ScreenPercentage.Default.PathTracer.Mode"), int32(EScreenPercentageMode::Manual),
	TEXT(""),
	ECVF_Scalability | ECVF_Default);

static TAutoConsoleVariable<float> CVarScreenPercentage(
	TEXT("r.ScreenPercentage"), 0.0f,

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LegacyScreenPercentageDriver.cpp:234

Scope (from outer to inner):

file
function     void FStaticResolutionFractionHeuristic::FUserSettings::PullRunTimeRenderingSettings

Source code excerpt:

		if (ViewStatus == EViewStatusForScreenPercentage::PathTracer)
		{
			Mode = EScreenPercentageMode(FMath::Clamp(CVarScreenPercentageDefaultPathTracerMode.GetValueOnGameThread(), 0, 2));
		}
		else if (ViewStatus == EViewStatusForScreenPercentage::VR)
		{
			Mode = EScreenPercentageMode(FMath::Clamp(CVarScreenPercentageDefaultVRMode.GetValueOnGameThread(), 0, 2));
		}
		else if (ViewStatus == EViewStatusForScreenPercentage::Mobile)