r.OIT.SortedTriangles
r.OIT.SortedTriangles
#Overview
name: r.OIT.SortedTriangles
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable per-instance triangle sorting to avoid invalid triangle ordering.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.OIT.SortedTriangles is to enable per-instance triangle sorting to avoid invalid triangle ordering in the Order-Independent Transparency (OIT) rendering system.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the OIT (Order-Independent Transparency) subsystem. It’s part of the rendering pipeline that handles transparent objects.
The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with an initial value of 1, meaning it’s enabled by default. The ECVF_ReadOnly and ECVF_RenderThreadSafe flags indicate that it’s read-only and safe to access from the render thread.
The associated variable CVarOIT_SortedTriangles_Enable_Project interacts directly with r.OIT.SortedTriangles. They share the same value and purpose. This associated variable is used in the IsSortedTrianglesEnabled function to determine if sorted triangles are enabled for a given shader platform.
Developers should be aware that this variable affects the rendering of transparent objects. Enabling it can improve the visual quality of overlapping transparent geometry by ensuring correct ordering of triangles within each instance. However, it may have performance implications due to the additional sorting step.
Best practices when using this variable include:
- Leaving it enabled (default value of 1) unless there are specific performance issues related to transparent object rendering.
- Testing the visual impact and performance with and without this feature enabled, especially in scenes with complex transparent geometry.
- Being aware that changing this variable at runtime may not be possible due to the ECVF_ReadOnly flag.
Regarding the associated variable CVarOIT_SortedTriangles_Enable_Project: Its purpose is identical to r.OIT.SortedTriangles, serving as an internal representation of the console variable. It’s used directly in the renderer code to check if sorted triangles are enabled. The value is retrieved using the GetValueOnAnyThread() method, which suggests it can be safely accessed from multiple threads. Developers should treat this variable as an implementation detail and interact with the feature through the r.OIT.SortedTriangles console variable instead.
#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:21
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarOIT_SortedTriangles_Enable_Project(
TEXT("r.OIT.SortedTriangles"),
1,
TEXT("Enable per-instance triangle sorting to avoid invalid triangle ordering."),
ECVF_ReadOnly | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarOIT_SortedTriangles_Debug(
TEXT("r.OIT.SortedTriangles.Debug"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarOIT_SortedTriangles_Enable_Project
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:20
Scope: file
Source code excerpt:
// Variables: sorted triangles
static TAutoConsoleVariable<int32> CVarOIT_SortedTriangles_Enable_Project(
TEXT("r.OIT.SortedTriangles"),
1,
TEXT("Enable per-instance triangle sorting to avoid invalid triangle ordering."),
ECVF_ReadOnly | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarOIT_SortedTriangles_Debug(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:817
Scope: file
Source code excerpt:
bool IsSortedTrianglesEnabled(EShaderPlatform InPlatform)
{
return CVarOIT_SortedTriangles_Enable_Project.GetValueOnAnyThread() > 0;
}
bool IsSortedPixelsEnabledForProject(EShaderPlatform InPlatform)
{
//const bool bMSAAEnabled = GetDefaultAntiAliasingMethod(GetMaxSupportedFeatureLevel(InPlatform)) != EAntiAliasingMethod::AAM_MSAA;
const bool bPixelOIT = CVarOIT_SortedPixels_Enable_Project.GetValueOnAnyThread() > 0 && FDataDrivenShaderPlatformInfo::GetSupportsOIT(EShaderPlatform(InPlatform));