r.Translucency.StandardSeparated

r.Translucency.StandardSeparated

#Overview

name: r.Translucency.StandardSeparated

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Translucency.StandardSeparated is to control whether translucent meshes are rendered in a separate buffer from the scene color. This setting is primarily used in the rendering system of Unreal Engine 5.

This setting variable is mainly relied upon by the Renderer module of Unreal Engine 5, specifically in the base pass rendering and scene rendering subsystems.

The value of this variable is set through a console variable (CVar) named CVarTranslucencyStandardSeparated. It is initialized with a default value of 0, which means the feature is disabled by default.

The r.Translucency.StandardSeparated variable interacts with another setting, r.SeparateTranslucency. If r.SeparateTranslucency is set to 0, r.Translucency.StandardSeparated is forcibly disabled.

Developers must be aware that enabling this feature prevents translucent meshes from self-refracting and leaking scene color behind edges when they should be affected by colored transmittance. However, it’s important to note that this feature is forced to be disabled when r.SeparateTranslucency is 0.

Best practices when using this variable include:

  1. Consider the performance implications of rendering translucent meshes in a separate buffer.
  2. Ensure that r.SeparateTranslucency is not set to 0 if you want to use this feature.
  3. Be aware of how this setting affects the visual quality of translucent objects in your scene.

Regarding the associated variable CVarTranslucencyStandardSeparated:

The purpose of CVarTranslucencyStandardSeparated is to serve as the console variable implementation of the r.Translucency.StandardSeparated setting. It allows for runtime modification of the setting through the console.

This variable is used directly in the Renderer module, particularly in the SceneRenderer initialization.

The value of CVarTranslucencyStandardSeparated is set when the console variable is created, with a default value of 0.

CVarTranslucencyStandardSeparated interacts directly with the r.Translucency.StandardSeparated setting, as they share the same value.

Developers should be aware that changes to CVarTranslucencyStandardSeparated will immediately affect the rendering behavior of translucent meshes.

Best practices for using CVarTranslucencyStandardSeparated include:

  1. Use it for debugging or testing different rendering configurations at runtime.
  2. Be cautious when modifying this value in a shipping game, as it can significantly impact performance and visual quality.
  3. Consider exposing this setting in a user-friendly way if you want to give players control over this aspect of rendering.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:254

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarTranslucencyStandardSeparated(
	TEXT("r.Translucency.StandardSeparated"),
	0,
	TEXT("Render translucent meshes in separate buffer from the scene color.\n")
	TEXT("This prevent those meshes from self refracting and leaking scnee color behind over edges when it should be affect by colored transmittance.\n")
	TEXT("Forced disabled when r.SeparateTranslucency is 0.\n"),
	ECVF_RenderThreadSafe | ECVF_Default);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:201

Scope (from outer to inner):

file
function     static bool IsStandardTranslucenyPassSeparated

Source code excerpt:

static bool IsStandardTranslucenyPassSeparated()
{
	static const auto TranslucencyStandardSeparatedCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Translucency.StandardSeparated"));
	return TranslucencyStandardSeparatedCVar && TranslucencyStandardSeparatedCVar->GetValueOnAnyThread() != 0;
}

template<uint32 StencilRef> void SetTranslucentPassDepthStencilState(FMeshPassProcessorRenderState& DrawRenderState, bool bDisableDepthTest)
{
	if (bDisableDepthTest)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:253

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarTranslucencyStandardSeparated(
	TEXT("r.Translucency.StandardSeparated"),
	0,
	TEXT("Render translucent meshes in separate buffer from the scene color.\n")
	TEXT("This prevent those meshes from self refracting and leaking scnee color behind over edges when it should be affect by colored transmittance.\n")
	TEXT("Forced disabled when r.SeparateTranslucency is 0.\n"),
	ECVF_RenderThreadSafe | ECVF_Default);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:2913

Scope (from outer to inner):

file
function     FSceneRenderer::FSceneRenderer

Source code excerpt:

		// When MSAA sample count is >1 it works, but hair has not been properly tested so far due to other issues, so MSAA cannot use separted standard translucent for now.
		uint32 MSAASampleCount = GetDefaultMSAACount(ViewFamily.GetFeatureLevel());
		ViewFamily.bAllowStandardTranslucencySeparated = SeparateTranslucencyEnabled && MSAASampleCount == 1 && !bIsMobile && CVarTranslucencyStandardSeparated.GetValueOnAnyThread() != 0;
	}

	check(!ViewFamily.AllViews.Num());
	ViewFamily.AllViews.Append(AllViews);

	Scene->CustomRenderPassRendererInputs.Reset();