r.OIT.SortedPixels.Enable

r.OIT.SortedPixels.Enable

#Overview

name: r.OIT.SortedPixels.Enable

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.OIT.SortedPixels.Enable is to control the enabling of Order Independent Transparency (OIT) rendering in Unreal Engine 5. This setting is specifically related to the rendering system, focusing on how transparent objects are rendered in the scene.

This setting variable is primarily used within the Renderer module of Unreal Engine, specifically in the OIT (Order Independent Transparency) subsystem. It’s defined and used in the OIT.cpp file, which is part of the core rendering pipeline.

The value of this variable is set as a console variable, initialized with a default value of 1 (enabled). It can be changed at runtime, as indicated by the ECVF_Scalability and ECVF_RenderThreadSafe flags.

This variable interacts closely with its associated variable CVarOIT_SortedPixels_Enable_Runtime. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects shader permutations. Changing its value at runtime will select different shader variants, which can impact rendering performance and visual quality.

Best practices when using this variable include:

  1. Consider the performance implications of enabling OIT, especially on lower-end hardware.
  2. Test thoroughly when changing this setting, as it can significantly affect the rendering of transparent objects.
  3. Be mindful of its interaction with MSAA (Multisample Anti-Aliasing), as the code suggests OIT is disabled when MSAA is active.

Regarding the associated variable CVarOIT_SortedPixels_Enable_Runtime:

The purpose of CVarOIT_SortedPixels_Enable_Runtime is essentially the same as r.OIT.SortedPixels.Enable. It’s used as the runtime counterpart to control OIT rendering.

This variable is used directly in the IsSortedPixelsEnabled functions to determine if OIT should be applied. It’s checked on the render thread, indicating its value can be changed dynamically during runtime.

The variable is defined with the ECVF_Scalability flag, suggesting that it’s intended to be adjusted based on the capabilities of the target hardware.

Developers should be aware that this variable’s value is queried on the render thread, so any changes to it will take effect in subsequent frames.

Best practices for CVarOIT_SortedPixels_Enable_Runtime include:

  1. Use it for dynamic adjustment of OIT based on performance metrics or user settings.
  2. Consider exposing it as a configurable option in graphics settings menus for end-users.
  3. Be cautious when changing its value frequently, as it can lead to shader recompilation and potential frame hitches.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:55

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarOIT_SortedPixels_Enable_Runtime(
	TEXT("r.OIT.SortedPixels.Enable"),
	1,
	TEXT("Enable OIT rendering (runtime setting, selects shader permutation)"),
	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarOIT_SortedPixels_PassType(
	TEXT("r.OIT.SortedPixels.PassType"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:54

Scope: file

Source code excerpt:

	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarOIT_SortedPixels_Enable_Runtime(
	TEXT("r.OIT.SortedPixels.Enable"),
	1,
	TEXT("Enable OIT rendering (runtime setting, selects shader permutation)"),
	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarOIT_SortedPixels_PassType(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:829

Scope: file

Source code excerpt:

	bool InternalIsSortedPixelsEnabled(EShaderPlatform InPlatform, bool bMSAA)
	{
		return IsSortedPixelsEnabledForProject(InPlatform) && GRHISupportsRasterOrderViews && !!CVarOIT_SortedPixels_Enable_Runtime.GetValueOnRenderThread() && !bMSAA;
	}
	bool IsSortedPixelsEnabled(const FViewInfo& InView) 	{ return InternalIsSortedPixelsEnabled(InView.GetShaderPlatform(), InView.AntiAliasingMethod == EAntiAliasingMethod::AAM_MSAA); }
	bool IsSortedPixelsEnabled(EShaderPlatform InPlatform)	{ return InternalIsSortedPixelsEnabled(InPlatform, false /*bMSAA*/); }
	
	bool IsSortedPixelsEnabledForPass(EOITPassType PassType)
	{