r.MaterialQualityLevel

r.MaterialQualityLevel

#Overview

name: r.MaterialQualityLevel

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

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.MaterialQualityLevel is to control the quality level of materials in Unreal Engine 5. This setting variable is used to adjust the visual fidelity of materials, allowing for scalability across different hardware capabilities and performance targets.

The r.MaterialQualityLevel variable is primarily used by the rendering system in Unreal Engine. It affects how materials are processed and displayed, particularly through the QualitySwitch material expression.

The value of this variable is typically set through the console, the editor UI, or programmatically. It can be modified using the SetMaterialQualityLevel function in the LevelEditorActionCallbacks class, as seen in the LevelEditorActions.cpp file.

This variable interacts with the EMaterialQualityLevel enum, which defines the possible quality levels (Low, High, Medium, and Epic). It also affects the behavior of the QualitySwitch material expression, allowing materials to adjust their appearance based on the current quality setting.

Developers should be aware that:

  1. The variable accepts values from 0 to 3, corresponding to Low (0), High (1), Medium (2), and Epic (3) quality levels.
  2. Changes to this variable can have a significant impact on performance and visual quality.
  3. It’s used for scalability purposes and should not be modified in construction scripts.

Best practices when using this variable include:

  1. Use it in conjunction with other scalability settings for a consistent experience across different hardware.
  2. Provide user-facing options to adjust this setting, allowing players to balance performance and visual quality.
  3. Test your game thoroughly at all quality levels to ensure acceptable performance and visual quality across the range of settings.
  4. When querying this value in game code, use the GetRenderingMaterialQualityLevel function from KismetSystemLibrary to ensure proper clamping of the value.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseScalability.ini:618, section: [EffectsQuality@0]

Location: <Workspace>/Engine/Config/BaseScalability.ini:645, section: [EffectsQuality@1]

Location: <Workspace>/Engine/Config/BaseScalability.ini:672, section: [EffectsQuality@2]

Location: <Workspace>/Engine/Config/BaseScalability.ini:699, section: [EffectsQuality@3]

Location: <Workspace>/Engine/Config/BaseScalability.ini:727, section: [EffectsQuality@Cine]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:3718

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarMaterialQualityLevel(
	TEXT("r.MaterialQualityLevel"),
	1,
	TEXT("0 corresponds to low quality materials, as defined by quality switches in materials, 1 corresponds to high, 2 for medium, and 3 for Epic."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarUseDXT5NormalMaps(
	TEXT("Compat.UseDXT5NormalMaps"),

#Loc: <Workspace>/Engine/Source/Editor/LevelEditor/Private/LevelEditorActions.cpp:626

Scope (from outer to inner):

file
function     void FLevelEditorActionCallbacks::SetMaterialQualityLevel

Source code excerpt:

void FLevelEditorActionCallbacks::SetMaterialQualityLevel( EMaterialQualityLevel::Type NewQualityLevel )
{
	static IConsoleVariable* MaterialQualityLevelVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.MaterialQualityLevel"));
	MaterialQualityLevelVar->Set(NewQualityLevel, ECVF_SetByScalability);

	GUnrealEd->OnSceneMaterialsModified();

	GUnrealEd->RedrawAllViewports();
}

#Loc: <Workspace>/Engine/Source/Editor/LevelEditor/Private/LevelEditorActions.cpp:636

Scope (from outer to inner):

file
function     bool FLevelEditorActionCallbacks::IsMaterialQualityLevelChecked

Source code excerpt:

bool FLevelEditorActionCallbacks::IsMaterialQualityLevelChecked( EMaterialQualityLevel::Type TestQualityLevel )
{
	static const auto MaterialQualityLevelVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MaterialQualityLevel"));
	EMaterialQualityLevel::Type MaterialQualityLevel = (EMaterialQualityLevel::Type)FMath::Clamp(MaterialQualityLevelVar->GetValueOnGameThread(), 0, (int32)EMaterialQualityLevel::Num-1);
	return TestQualityLevel == MaterialQualityLevel;
}

void FLevelEditorActionCallbacks::ToggleFeatureLevelPreview()
{

#Loc: <Workspace>/Engine/Source/Editor/LevelEditor/Private/LevelEditorToolBar.cpp:1769

Scope (from outer to inner):

file
function     void FLevelEditorToolBar::RegisterQuickSettingsMenu

Source code excerpt:

			"MaterialQualityLevel",
			LOCTEXT( "MaterialQualityLevelSubMenu", "Material Quality Level" ),
			LOCTEXT( "MaterialQualityLevelSubMenu_ToolTip", "Sets the value of the CVar \"r.MaterialQualityLevel\" (low=0, high=1, medium=2, Epic=3). This affects materials via the QualitySwitch material expression." ),
			FNewToolMenuDelegate::CreateStatic( &MakeMaterialQualityLevelMenu ) );

		Section.AddSubMenu(
			"FeatureLevelPreview",
			LOCTEXT("PreviewPlatformSubMenu", "Preview Platform"),
			LOCTEXT("PreviewPlatformSubMenu_ToolTip", "Sets the preview platform used by the main editor"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Kismet/KismetSystemLibrary.h:1636

Scope: file

Source code excerpt:


	/**
	 * Get the clamped state of r.MaterialQualityLevel, see console variable help (allows for scalability, cannot be used in construction scripts)
	 * 0: low
	 * 1: high
	 * 2: medium
	 */
	UFUNCTION(BlueprintPure, Category="Rendering|Material", meta=(UnsafeDuringActorConstruction = "true"))
	static ENGINE_API int32 GetRenderingMaterialQualityLevel();

	/**
	 * Gets the list of support fullscreen resolutions.
	 * @return true if successfully queried the device for available resolutions.
	 */

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/KismetSystemLibrary.cpp:2645

Scope (from outer to inner):

file
function     int32 UKismetSystemLibrary::GetRenderingMaterialQualityLevel

Source code excerpt:

int32 UKismetSystemLibrary::GetRenderingMaterialQualityLevel()
{
	static const IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.MaterialQualityLevel"));

	// clamp range
	int32 Ret = FMath::Clamp(CVar->GetInt(), 0, (int32)EMaterialQualityLevel::Num - 1);

	return Ret;
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:791

Scope (from outer to inner):

file
function     void ScalabilityCVarsSinkCallback

Source code excerpt:


	{
		static const auto MaterialQualityLevelVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MaterialQualityLevel"));
		LocalScalabilityCVars.MaterialQualityLevel = (EMaterialQualityLevel::Type)FMath::Clamp(MaterialQualityLevelVar->GetValueOnGameThread(), 0, (int32)EMaterialQualityLevel::Num - 1);
	}

	{
		static const auto StaticMeshLODDistanceScale = IConsoleManager::Get().FindConsoleVariable(TEXT("r.StaticMeshLODDistanceScale"));
		LocalScalabilityCVars.StaticMeshLODDistanceScale = StaticMeshLODDistanceScale->GetFloat();