r.OIT.SortedPixels.TransmittanceThreshold

r.OIT.SortedPixels.TransmittanceThreshold

#Overview

name: r.OIT.SortedPixels.TransmittanceThreshold

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.TransmittanceThreshold is to control the removal of translucent rendering surfaces in the Order-Independent Transparency (OIT) system. It sets a threshold for accumulated transmittance, below which translucent surfaces are culled from rendering.

This setting variable is primarily used in the rendering system, specifically in the Order-Independent Transparency (OIT) subsystem of Unreal Engine 5. Based on the callsites, it’s utilized in the Renderer module, particularly in the OIT implementation.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0.05 and can be adjusted at runtime.

The associated variable CVarOIT_SortedPixels_TransmittanceThreshold interacts directly with r.OIT.SortedPixels.TransmittanceThreshold. They share the same value and purpose.

Developers must be aware that this variable affects the visual quality and performance of translucent object rendering. A lower threshold may improve visual quality but potentially at the cost of performance, while a higher threshold might improve performance but could lead to visible artifacts in translucent objects.

Best practices when using this variable include:

  1. Carefully balancing visual quality and performance requirements.
  2. Testing different threshold values to find the optimal setting for your specific scene.
  3. Considering the nature of translucent objects in your game when adjusting this value.
  4. Using it in conjunction with other OIT-related settings for best results.

Regarding the associated variable CVarOIT_SortedPixels_TransmittanceThreshold:

This is the actual console variable that controls the transmittance threshold. It’s defined using the TAutoConsoleVariable template, which allows for runtime modification of the value. The variable is used in the FOITSortTriangleIndex_WriteOutCS class, which is likely part of the OIT sorting and writing process.

The value is retrieved using GetValueOnRenderThread() and then clamped between 0 and 1, ensuring it stays within a valid range. This clamped value is then used in the OIT rendering process to determine which translucent surfaces should be rendered.

Developers should note that changes to this variable will take effect on the render thread, which means there might be a slight delay before seeing the results of any adjustments made during runtime.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarOIT_SortedPixels_TransmittanceThreshold(
	TEXT("r.OIT.SortedPixels.TransmittanceThreshold"),
	0.05,
	TEXT("Remove translucent rendering surfaces when the accumulated thransmittance is below this threshold"),
	ECVF_RenderThreadSafe);

///////////////////////////////////////////////////////////////////////////////////////////////////

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarOIT_SortedPixels_TransmittanceThreshold(
	TEXT("r.OIT.SortedPixels.TransmittanceThreshold"),
	0.05,
	TEXT("Remove translucent rendering surfaces when the accumulated thransmittance is below this threshold"),
	ECVF_RenderThreadSafe);

///////////////////////////////////////////////////////////////////////////////////////////////////

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

Scope (from outer to inner):

file
class        class FOITSortTriangleIndex_WriteOutCS : public FGlobalShader

Source code excerpt:

			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"));
		}

		// TODO: Add tile clear based on the coarse translucent raster AABB buffer