r.OIT.SortedPixels.PassType
r.OIT.SortedPixels.PassType
#Overview
name: r.OIT.SortedPixels.PassType
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable OIT rendering. 0: disable 1: enable OIT for std. translucency 2: enable OIT for separated translucency 3: enable for both std. and separated translucency (default)
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.OIT.SortedPixels.PassType is to control the enabling of Order Independent Transparency (OIT) rendering for different types of translucency passes in Unreal Engine 5’s rendering system.
This setting variable is primarily used by the Renderer module, specifically in the OIT (Order Independent Transparency) subsystem. It’s referenced in the file OIT.cpp, which is part of the runtime rendering system.
The value of this variable is set through a console variable (CVarOIT_SortedPixels_PassType) with a default value of 3. It can be changed at runtime through console commands or programmatically.
The variable interacts with the EOITPassType enum, which likely defines different types of translucency passes. The IsSortedPixelsEnabledForPass function uses this variable to determine whether OIT should be enabled for a specific pass type.
Developers should be aware that this variable affects both standard and separated translucency. The value ranges from 0 to 3, with each value enabling different combinations of translucency types: 0: Disable OIT 1: Enable OIT for standard translucency 2: Enable OIT for separated translucency 3: Enable OIT for both standard and separated translucency (default)
Best practices when using this variable include:
- Consider performance implications when enabling OIT for both types of translucency.
- Test different settings to find the optimal balance between visual quality and performance for your specific use case.
- Be aware that changing this setting may affect the appearance of translucent objects in your scene.
Regarding the associated variable CVarOIT_SortedPixels_PassType:
This is the actual console variable that stores and manages the value of r.OIT.SortedPixels.PassType. It’s defined using TAutoConsoleVariable, which allows it to be changed at runtime.
The purpose of CVarOIT_SortedPixels_PassType is to provide a programmable interface for changing the OIT pass type setting. It’s used internally by the engine to retrieve the current setting value, as seen in the IsSortedPixelsEnabledForPass function.
This variable is set in the same file (OIT.cpp) where it’s defined, with a default value of 3. It’s marked as ECVF_RenderThreadSafe, indicating that it’s safe to access from the render thread.
Developers should be aware that modifying this variable directly (rather than through the console command) requires proper threading considerations, as it’s accessed from the render thread.
Best practices for using CVarOIT_SortedPixels_PassType include:
- Use the console command interface (r.OIT.SortedPixels.PassType) for runtime changes rather than modifying the variable directly.
- If programmatic access is needed, ensure thread safety when reading or writing to this variable.
- Consider exposing this setting in your game’s graphics options menu to allow users to adjust OIT behavior for performance tuning.
#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:61
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarOIT_SortedPixels_PassType(
TEXT("r.OIT.SortedPixels.PassType"),
3,
TEXT("Enable OIT rendering. 0: disable 1: enable OIT for std. translucency 2: enable OIT for separated translucency 3: enable for both std. and separated translucency (default)"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarOIT_SortedPixels_SampleCount(
TEXT("r.OIT.SortedPixels.MaxSampleCount"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarOIT_SortedPixels_PassType
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:60
Scope: file
Source code excerpt:
ECVF_Scalability | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarOIT_SortedPixels_PassType(
TEXT("r.OIT.SortedPixels.PassType"),
3,
TEXT("Enable OIT rendering. 0: disable 1: enable OIT for std. translucency 2: enable OIT for separated translucency 3: enable for both std. and separated translucency (default)"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarOIT_SortedPixels_SampleCount(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:836
Scope: file
Source code excerpt:
bool IsSortedPixelsEnabledForPass(EOITPassType PassType)
{
const uint32 PassTypeBits = FMath::Clamp(CVarOIT_SortedPixels_PassType.GetValueOnRenderThread(), 0, 3);
return !!(PassTypeBits & PassType);
}
bool IsCompatible(const FMeshBatch& InMesh, ERHIFeatureLevel::Type InFeatureLevel)
{
// Only support local vertex factory at the moment as we need to have direct access to the position
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:916
Scope (from outer to inner):
file
class class FOITSortTriangleIndex_WriteOutCS : public FGlobalShader
Source code excerpt:
{
const bool bOIT = IsSortedPixelsEnabled(View);
const uint32 PassTypeBits = FMath::Clamp(CVarOIT_SortedPixels_PassType.GetValueOnRenderThread(), 0, 3);
const bool bPassValid = !!(PassTypeBits & PassType);
const uint32 LayerCount = 3u; /*Depth/Color/Trans*/
FOITData Out;
if (!bOIT || !bPassValid)
{