r.Editor.Viewport.MaxRenderingResolution

r.Editor.Viewport.MaxRenderingResolution

#Overview

name: r.Editor.Viewport.MaxRenderingResolution

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

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Editor.Viewport.MaxRenderingResolution is to control the absolute maximum number of rendered pixels in editor viewports. This setting variable is primarily used in the rendering system of Unreal Engine 5, specifically for editor viewports.

The Unreal Engine subsystems that rely on this setting variable are:

  1. The Editor subsystem, particularly the viewport rendering component.
  2. The Engine’s LegacyScreenPercentageDriver module.

The value of this variable is set in multiple places:

  1. It is initially defined with a default value of 2160 in EditorProjectSettings.cpp.
  2. It can be modified through project settings in the UEditorPerformanceProjectSettings class.
  3. It can be overridden by user settings in the UEditorPerformanceSettings class.

This variable interacts with several other variables, including:

  1. r.Editor.Viewport.ScreenPercentage
  2. r.Editor.Viewport.MinRenderingResolution

Developers should be aware of the following when using this variable:

  1. It directly impacts the rendering quality and performance of editor viewports.
  2. Changes to this variable will affect all editor viewports.
  3. It can be overridden by both project and user settings.

Best practices when using this variable include:

  1. Consider the hardware capabilities of target machines when setting this value.
  2. Balance between visual quality and performance, especially for less powerful development machines.
  3. Use in conjunction with MinRenderingResolution to define an appropriate range for viewport rendering.

Regarding the associated variable CVarEditorViewportDefaultMaxRenderingResolution:

This is the console variable representation of r.Editor.Viewport.MaxRenderingResolution. It serves the same purpose and is used to interact with the setting programmatically.

The value of CVarEditorViewportDefaultMaxRenderingResolution is set and accessed in the following ways:

  1. It’s initialized with the same default value (2160) as r.Editor.Viewport.MaxRenderingResolution.
  2. It’s updated when project or user settings are applied through the ExportResolutionValuesToConsoleVariables() function.
  3. It’s read in the LegacyScreenPercentageDriver to determine the maximum rendering resolution for viewports.

Developers should be aware that changes to this console variable will have immediate effects on the editor viewport rendering. It’s important to use the appropriate methods (like project or user settings) to modify this value rather than changing it directly through the console, to ensure consistency across the engine.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorProjectSettings.cpp:46

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarEditorViewportDefaultMaxRenderingResolution(
	TEXT("r.Editor.Viewport.MaxRenderingResolution"), 2160,
	TEXT("Controls the absolute maximum number of rendered pixel in editor viewports."),
	ECVF_Default);


EUnit ConvertDefaultInputUnits(EDefaultLocationUnit In)
{

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

Scope: file

Source code excerpt:

	static auto CVarEditorViewportDefaultScreenPercentage = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Editor.Viewport.ScreenPercentage"));
	static auto CVarEditorViewportDefaultMinRenderingResolution = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Editor.Viewport.MinRenderingResolution"));
	static auto CVarEditorViewportDefaultMaxRenderingResolution = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Editor.Viewport.MaxRenderingResolution"));

	if (ViewStatus == EViewStatusForScreenPercentage::PathTracer)
	{
		Mode = EScreenPercentageMode(FMath::Clamp(CVarEditorViewportDefaultScreenPercentagePathTracerMode->GetInt(), 0, 2));
	}
	else if (ViewStatus == EViewStatusForScreenPercentage::VR)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorProjectSettings.cpp:45

Scope: file

Source code excerpt:

	ECVF_Default);

TAutoConsoleVariable<int32> CVarEditorViewportDefaultMaxRenderingResolution(
	TEXT("r.Editor.Viewport.MaxRenderingResolution"), 2160,
	TEXT("Controls the absolute maximum number of rendered pixel in editor viewports."),
	ECVF_Default);


EUnit ConvertDefaultInputUnits(EDefaultLocationUnit In)

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorProjectSettings.cpp:297

Scope (from outer to inner):

file
function     void UEditorPerformanceProjectSettings::ExportResolutionValuesToConsoleVariables

Source code excerpt:

		CVarEditorViewportDefaultScreenPercentage->Set(EditorProjectSettings->ManualScreenPercentage, ECVF_SetByProjectSetting);
		CVarEditorViewportDefaultMinRenderingResolution->Set(EditorProjectSettings->MinViewportRenderingResolution, ECVF_SetByProjectSetting);
		CVarEditorViewportDefaultMaxRenderingResolution->Set(EditorProjectSettings->MaxViewportRenderingResolution, ECVF_SetByProjectSetting);
	}


	// Override with the per editor user settings
	{
		const UEditorPerformanceSettings* EditorUserSettings = GetDefault<UEditorPerformanceSettings>();

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorProjectSettings.cpp:340

Scope (from outer to inner):

file
function     void UEditorPerformanceProjectSettings::ExportResolutionValuesToConsoleVariables

Source code excerpt:

		if (EditorUserSettings->bOverrideMaxViewportRenderingResolution)
		{
			CVarEditorViewportDefaultMaxRenderingResolution->Set(EditorUserSettings->MaxViewportRenderingResolution, ECVF_SetByProjectSetting);
		}
	}

	// Tell all viewports to refresh their screen percentage when the dpi scaling override changes
	if (GEngine && GEditor)
	{

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

Scope: file

Source code excerpt:

	static auto CVarEditorViewportDefaultScreenPercentage = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Editor.Viewport.ScreenPercentage"));
	static auto CVarEditorViewportDefaultMinRenderingResolution = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Editor.Viewport.MinRenderingResolution"));
	static auto CVarEditorViewportDefaultMaxRenderingResolution = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Editor.Viewport.MaxRenderingResolution"));

	if (ViewStatus == EViewStatusForScreenPercentage::PathTracer)
	{
		Mode = EScreenPercentageMode(FMath::Clamp(CVarEditorViewportDefaultScreenPercentagePathTracerMode->GetInt(), 0, 2));
	}
	else if (ViewStatus == EViewStatusForScreenPercentage::VR)

#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