r.OIT.SortedPixels.Method

r.OIT.SortedPixels.Method

#Overview

name: r.OIT.SortedPixels.Method

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.Method is to control the Order-Independent Transparency (OIT) method used in the rendering system. This setting variable is part of Unreal Engine’s rendering subsystem, specifically related to the OIT implementation.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, as evidenced by its location in the ‘Runtime/Renderer/Private/OIT/OIT.cpp’ file.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, which corresponds to the MLAB (Memory-Limited A-Buffer) method. The value can be changed at runtime through console commands or programmatically.

This variable interacts with another variable named CVarOIT_SortedPixels_Method, which is the actual TAutoConsoleVariable object that stores and manages the value.

Developers must be aware that this variable accepts values 0 and 1, where 0 represents regular alpha-blending (no OIT) and 1 represents the MLAB method. Any other values will be clamped to this range.

Best practices when using this variable include:

  1. Only changing it when necessary, as switching OIT methods can have performance implications.
  2. Testing the impact of different methods on visual quality and performance for your specific use case.
  3. Considering the hardware capabilities of your target platforms, as more advanced OIT methods may be more demanding.

Regarding the associated variable CVarOIT_SortedPixels_Method:

The purpose of CVarOIT_SortedPixels_Method is to provide a programmatic interface for getting and setting the OIT method. It’s the actual console variable object that stores the value of r.OIT.SortedPixels.Method.

This variable is part of the Unreal Engine’s console variable system, which is used across various subsystems for runtime configuration.

The value of this variable is set when the engine initializes the console variables, but it can be changed at runtime through console commands or programmatically using the console variable interface.

CVarOIT_SortedPixels_Method interacts directly with the r.OIT.SortedPixels.Method setting. Changes to one will affect the other.

Developers should be aware that this variable is of type TAutoConsoleVariable, which means it stores an integer value. They should use the appropriate methods to get and set its value, such as GetValueOnRenderThread() as seen in the code.

Best practices for using this variable include:

  1. Using the appropriate thread-safe methods to access its value, especially in render thread code.
  2. Being cautious when changing its value, as it directly affects the rendering pipeline.
  3. Considering wrapping access to this variable in higher-level functions that handle the clamping and any associated logic for changing the OIT method.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarOIT_SortedPixels_Method(
	TEXT("r.OIT.SortedPixels.Method"),
	1,
	TEXT("Toggle OIT methods 0: Regular alpha-blending (i.e., no OIT) 1: MLAB"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarOIT_SortedPixels_TransmittanceThreshold(
	TEXT("r.OIT.SortedPixels.TransmittanceThreshold"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarOIT_SortedPixels_Method(
	TEXT("r.OIT.SortedPixels.Method"),
	1,
	TEXT("Toggle OIT methods 0: Regular alpha-blending (i.e., no OIT) 1: MLAB"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarOIT_SortedPixels_TransmittanceThreshold(

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

Scope (from outer to inner):

file
class        class FOITSortTriangleIndex_WriteOutCS : public FGlobalShader

Source code excerpt:

			Out.MaxSideSamplePerPixel = MaxSideSamplePerPixel;
			Out.MaxSamplePerPixel = MaxSamplePerPixel;
			Out.Method = FMath::Clamp(CVarOIT_SortedPixels_Method.GetValueOnRenderThread(), 0, 1);
			Out.TransmittanceThreshold = FMath::Clamp(CVarOIT_SortedPixels_TransmittanceThreshold.GetValueOnRenderThread(), 0.f, 1.f);

			Out.SampleDataTexture = GraphBuilder.CreateTexture(FRDGTextureDesc::Create2DArray(EffectiveBufferSize * MaxSideSamplePerPixel, PF_R32_UINT, FClearValueBinding::None, TexCreate_ShaderResource | TexCreate_UAV, LayerCount), TEXT("OIT.SampleData"));
			Out.SampleCountTexture = GraphBuilder.CreateTexture(FRDGTextureDesc::Create2D(EffectiveBufferSize, PF_R32_UINT, FClearValueBinding::None, TexCreate_ShaderResource | TexCreate_UAV), TEXT("OIT.SampleCount"));
		}