MaxRenderingResolution

MaxRenderingResolution

#Overview

name: MaxRenderingResolution

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of MaxRenderingResolution is to set an upper limit on the rendering resolution in Unreal Engine 5’s screen percentage system. This variable is part of the rendering system, specifically the dynamic resolution and screen percentage features.

MaxRenderingResolution is primarily used in the Engine module, particularly within the legacy screen percentage driver. Based on the callsites, it’s clear that this setting is crucial for managing the maximum rendering resolution in both game and editor viewport contexts.

The value of this variable is typically set through console variables (CVars) or configuration files. In the game context, it’s set using the CVar CVarScreenPercentageMaxResolution, while in the editor viewport, it uses CVarEditorViewportDefaultMaxRenderingResolution. It can also be loaded from the engine configuration file (GEngineIni) under the “Rendering.AutoScreenPercentage” section.

MaxRenderingResolution interacts closely with other variables in the screen percentage system, such as MinRenderingResolution and GlobalResolutionFraction. It works in tandem with these to determine the final rendering resolution.

Developers must be aware that this variable acts as a cap on the rendering resolution, even when other factors might suggest a higher resolution. It’s particularly important in scenarios where dynamic resolution scaling is in use, as it prevents the resolution from scaling beyond a certain point, which could impact performance.

Best practices when using this variable include:

  1. Setting it appropriately for the target hardware to ensure a balance between visual quality and performance.
  2. Considering it in conjunction with MinRenderingResolution to define a sensible range for dynamic resolution scaling.
  3. Testing thoroughly across different scenarios to ensure it doesn’t negatively impact visual quality or performance unexpectedly.
  4. Being cautious when modifying it at runtime, as sudden changes could be jarring to players.
  5. Documenting any custom settings or modifications for future reference and easier debugging.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:2025, section: [Rendering.AutoScreenPercentage]

#References in C++ code

#Callsites

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

#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:308

Scope: file

Source code excerpt:

	GlobalResolutionFraction = GetResolutionFraction(CVarEditorViewportDefaultScreenPercentage->GetInt());
	MinRenderingResolution = CVarEditorViewportDefaultMinRenderingResolution->GetInt();
	MaxRenderingResolution = CVarEditorViewportDefaultMaxRenderingResolution->GetInt();
}
#else
{
	unimplemented();
}
#endif

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

Scope (from outer to inner):

file
function     float FStaticResolutionFractionHeuristic::ResolveResolutionFraction

Source code excerpt:

			bSuccess = bSuccess && GConfig->GetFloat(TEXT("Rendering.AutoScreenPercentage"), TEXT("MinRenderingResolution"), AutoMinRenderingResolution, GEngineIni);
			bSuccess = bSuccess && GConfig->GetFloat(TEXT("Rendering.AutoScreenPercentage"), TEXT("MidRenderingResolution"), AutoMidRenderingResolution, GEngineIni);
			bSuccess = bSuccess && GConfig->GetFloat(TEXT("Rendering.AutoScreenPercentage"), TEXT("MaxRenderingResolution"), AutoMaxRenderingResolution, GEngineIni);
			if (!bSuccess)
			{
				UE_LOG(LogEngine, Fatal, TEXT("Failed to load Rendering.AutoScreenPercentage ini section."));
			}
			bInitPixelCount = true;
		}

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

Scope (from outer to inner):

file
function     float FStaticResolutionFractionHeuristic::ResolveResolutionFraction

Source code excerpt:


	// Max the rendering resolution to average target resolution used on platform that have dynamic resolution.
	const float MaxRenderingPixelCount = GetRenderingPixelCount(Settings.MaxRenderingResolution);
	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);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/LegacyScreenPercentageDriver.h:95

Scope: file

Source code excerpt:

		// r.ScreenPercentage.{Min,Max}Resolution
		float MinRenderingResolution = 0.0f;
		float MaxRenderingResolution = 0.0f;

		// r.ScreenPercentage.Auto.* Mode = EMode::BasedOnDisplayResolution.
		float AutoPixelCountMultiplier = 1.0f;

		// stereo HMDs cannot use percentage modes based on 2D monitor
		bool bAllowDisplayBasedScreenPercentageMode = true;