r.MSAA.CompositingSampleCount

r.MSAA.CompositingSampleCount

#Overview

name: r.MSAA.CompositingSampleCount

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.MSAA.CompositingSampleCount is to control the Multi-Sample Anti-Aliasing (MSAA) quality for rendering 3D objects in the Unreal Engine editor. It specifically affects the compositing sample count, which determines the level of anti-aliasing applied to editor objects.

This setting variable is primarily used by the Unreal Engine’s rendering system, particularly in the editor environment. Based on the callsites, it’s utilized in the Core, UnrealEd, and Engine modules of Unreal Engine.

The value of this variable is set through the console variable system. It’s defined as a TAutoConsoleVariable in the ConsoleManager.cpp file, with a default value of 4.

The variable interacts with other parts of the rendering system, particularly those dealing with MSAA and editor object rendering. It’s used in conjunction with feature level checks (ERHIFeatureLevel::SM5) and other rendering capabilities (GRHISupportsMSAADepthSampleAccess).

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

  1. It only affects editor rendering, not in-game graphics.
  2. Higher values provide better quality but increase GPU memory consumption.
  3. It’s only supported on Shader Model 5 (SM5) and above.
  4. The actual effect depends on hardware support for MSAA depth sample access.

Best practices for using this variable include:

  1. Consider the trade-off between visual quality and performance. Higher values (4 or 8) provide better quality but may impact editor performance on less powerful hardware.
  2. Be mindful of the GPU memory consumption, especially when working on projects with complex scenes or on machines with limited GPU memory.
  3. Adjust this setting based on the specific needs of your project and your development hardware capabilities.
  4. Remember that this setting doesn’t affect the final game quality, so don’t rely on it for judging in-game anti-aliasing.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarMSAACompositingSampleCount(
	TEXT("r.MSAA.CompositingSampleCount"),
	4,
	TEXT("Affects the render quality of the editor 3d objects.\n"
		 " 1: no MSAA, lowest quality\n"
		 " 2: 2x MSAA, medium quality (medium GPU memory consumption)\n"
		 " 4: 4x MSAA, high quality (high GPU memory consumption)\n"
		 " 8: 8x MSAA, very high quality (insane GPU memory consumption)"),

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorComponents.cpp:67

Scope (from outer to inner):

file
function     static bool IsEditorCompositingMSAAEnabled

Source code excerpt:

	{
		// only supported on SM5 yet
		static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MSAA.CompositingSampleCount"));

		Ret = CVar->GetValueOnGameThread() > 1;
	}

	return Ret;
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneTexturesConfig.cpp:186

Scope (from outer to inner):

file
function     static uint32 GetEditorPrimitiveNumSamples

Source code excerpt:

	if (FeatureLevel >= ERHIFeatureLevel::SM5 && GRHISupportsMSAADepthSampleAccess)
	{
		static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MSAA.CompositingSampleCount"));

		SampleCount = CVar->GetValueOnAnyThread();

		if (SampleCount <= 1)
		{
			SampleCount = 1;