r.ScreenPercentage.MaxResolution

r.ScreenPercentage.MaxResolution

#Overview

name: r.ScreenPercentage.MaxResolution

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.ScreenPercentage.MaxResolution is to control the maximum number of rendered pixels before any upscaling, ensuring that the rendering resolution doesn’t exceed a specified 16:9 resolution. This setting is part of Unreal Engine’s rendering system, specifically related to screen percentage and dynamic resolution features.

This setting variable is primarily used in the Engine module, particularly within the LegacyScreenPercentageDriver.cpp file. It’s part of the screen percentage and dynamic resolution system, which helps manage rendering performance across different hardware configurations.

The value of this variable is set through a console variable (CVar) named CVarScreenPercentageMaxResolution. It’s initialized with a default value of 0.0f, which means no limit by default. Developers can modify this value through game settings, configuration files, or at runtime using console commands.

The r.ScreenPercentage.MaxResolution variable interacts closely with other screen percentage-related variables, such as:

  1. CVarScreenPercentage (r.ScreenPercentage)
  2. CVarScreenPercentageMinResolution (r.ScreenPercentage.MinResolution)
  3. CVarAutoPixelCountMultiplier (r.AutoPixelCountMultiplier)

These variables work together to control the dynamic resolution system in Unreal Engine.

Developers should be aware that:

  1. This setting is particularly useful for maintaining consistent performance between development (PIE) and target platforms.
  2. It’s recommended to set this value in the project’s DefaultEditor.ini file for PC development to avoid rendering more pixels than intended for the target platform.
  3. The value represents the height of a 16:9 resolution. For example, setting it to 1440 would limit rendering to 2560x1440 (3.6M pixels) at maximum.

Best practices when using this variable include:

  1. Set it to match the maximum resolution of your target platform to ensure consistent performance during development.
  2. Use it in conjunction with other screen percentage settings for fine-tuned control over rendering resolution.
  3. Consider the performance implications of changing this value, especially on lower-end hardware.

Regarding the associated variable CVarScreenPercentageMaxResolution:

This is the actual console variable that stores and manages the r.ScreenPercentage.MaxResolution value. It’s defined using TAutoConsoleVariable, which allows it to be modified at runtime. The variable is used in various parts of the LegacyScreenPercentageDriver to retrieve the current max resolution setting and apply it to the rendering pipeline.

Developers should interact with this setting primarily through the r.ScreenPercentage.MaxResolution console command or by modifying the appropriate configuration files, rather than directly manipulating the CVarScreenPercentageMaxResolution variable in code.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarScreenPercentageMaxResolution(
	TEXT("r.ScreenPercentage.MaxResolution"),
	0.0f,
	TEXT("Controls the absolute maximum number of rendered pixel before any upscaling such that doesn't go higher than the specified 16:9 resolution ")
	TEXT("of this variable. For instance set this value to 1440 so that you are not rendering more than 2560x1440 = 3.6M pixels. ")
	TEXT("This is useful to set this on PC in your project's DefaultEditor.ini so you are not rendering more pixel on PC in PIE that you would ")
	TEXT("in average on console with your project specific dynamic resolution settings."),
	ECVF_Default);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_Default);

static TAutoConsoleVariable<float> CVarScreenPercentageMaxResolution(
	TEXT("r.ScreenPercentage.MaxResolution"),
	0.0f,
	TEXT("Controls the absolute maximum number of rendered pixel before any upscaling such that doesn't go higher than the specified 16:9 resolution ")
	TEXT("of this variable. For instance set this value to 1440 so that you are not rendering more than 2560x1440 = 3.6M pixels. ")
	TEXT("This is useful to set this on PC in your project's DefaultEditor.ini so you are not rendering more pixel on PC in PIE that you would ")
	TEXT("in average on console with your project specific dynamic resolution settings."),

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

Scope (from outer to inner):

file
function     void FStaticResolutionFractionHeuristic::FUserSettings::PullRunTimeRenderingSettings

Source code excerpt:

	float GlobalResolutionFractionOverride = GetResolutionFraction(CVarScreenPercentage.GetValueOnGameThread());
	MinRenderingResolution = CVarScreenPercentageMinResolution.GetValueOnGameThread();
	MaxRenderingResolution = CVarScreenPercentageMaxResolution.GetValueOnGameThread();

	if (GlobalResolutionFractionOverride > 0.0)
	{
		Mode = EScreenPercentageMode::Manual;
		GlobalResolutionFraction = GlobalResolutionFractionOverride;
		AutoPixelCountMultiplier = CVarAutoPixelCountMultiplier.GetValueOnGameThread();

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

Scope (from outer to inner):

file
function     void FStaticResolutionFractionHeuristic::FUserSettings::PullRunTimeRenderingSettings

Source code excerpt:

	GlobalResolutionFraction = GetResolutionFraction(CVarScreenPercentage.GetValueOnGameThread());
	MinRenderingResolution = CVarScreenPercentageMinResolution.GetValueOnGameThread();
	MaxRenderingResolution = CVarScreenPercentageMaxResolution.GetValueOnGameThread();
	AutoPixelCountMultiplier = CVarAutoPixelCountMultiplier.GetValueOnGameThread();

	if (GlobalResolutionFraction <= 0.0)
	{
		GlobalResolutionFraction = 1.0f;
		Mode = EScreenPercentageMode::Manual;

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

Scope (from outer to inner):

file
function     float FStaticResolutionFractionHeuristic::ResolveResolutionFraction

Source code excerpt:

	if (MaxRenderingPixelCount > 0.0f)
	{
		// Compute max resolution fraction such that the total number of pixel doesn't go over the CVarScreenPercentageMaxResolution.
		float MaxGlobalResolutionFraction = FMath::Sqrt(float(MaxRenderingPixelCount) / float(LocalTotalDisplayedPixelCount));

		GlobalResolutionFraction = FMath::Min(GlobalResolutionFraction, MaxGlobalResolutionFraction);
	}

	// Min the rendering resolution to avoid any upscaling at very low resolutions.