r.VRS.Translucency

r.VRS.Translucency

#Overview

name: r.VRS.Translucency

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.VRS.Translucency is to enable and control Variable Rate Shading (VRS) for translucency rendering in Unreal Engine 5. This setting is part of the rendering system, specifically the Variable Rate Shading feature.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, particularly in the VariableRateShadingImageManager component. Based on the callsites, it’s clear that this variable is crucial for the VRS system when dealing with translucent objects in the scene.

The value of this variable is set through a console variable (CVarVRSTranslucency) with three possible options: 0: Disabled 1: Full (default) 2: Conservative

The variable interacts with other VRS-related variables, as seen in the associated callsite where it’s part of an array of VRS settings for different pass types (CVarByPassType).

Developers must be aware that changing this setting will affect the performance and visual quality of translucent objects in the scene. The “Conservative” option (2) likely provides a balance between performance gain and visual quality, while “Full” (1) maximizes the VRS effect.

Best practices when using this variable include:

  1. Testing different settings to find the optimal balance between performance and visual quality for your specific project.
  2. Being cautious when disabling it (0) as it might impact performance, especially in scenes with many translucent objects.
  3. Considering the interaction with other VRS settings for a cohesive rendering approach.

Regarding the associated variable CVarVRSTranslucency:

This is the actual console variable that controls the r.VRS.Translucency setting. It’s an integer variable that directly corresponds to the r.VRS.Translucency setting.

The purpose of CVarVRSTranslucency is to provide a programmable interface for changing the VRS translucency setting at runtime. It’s used internally by the engine to query and modify the current VRS translucency state.

This variable is part of the Renderer module and is crucial for the Variable Rate Shading system’s functionality regarding translucent objects.

The value is set when the console variable is created, with a default value of 1 (Full VRS for translucency).

CVarVRSTranslucency interacts with other VRS-related console variables, as seen in the CVarByPassType array.

Developers should be aware that modifying this variable directly (rather than through the r.VRS.Translucency console command) will have the same effect on the VRS system. They should also note the FConsoleVariableDelegate attached to it, which suggests that changing this value might trigger additional actions in the engine.

Best practices include using the r.VRS.Translucency console command to modify this setting rather than directly changing the CVarVRSTranslucency variable, as the console command ensures proper handling and potential side effects are managed correctly.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VariableRateShading/VariableRateShadingImageManager.cpp:96

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);
TAutoConsoleVariable<int32> CVarVRSTranslucency(
	TEXT("r.VRS.Translucency"),
	1,
	TEXT("Enable VRS with translucency rendering.\n")
	TEXT("0: Disabled")
	TEXT("1: Full (default)")
	TEXT("2: Conservative"),
	FConsoleVariableDelegate::CreateStatic(&CVarVRSImagePassTypeCallback),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VariableRateShading/VariableRateShadingImageManager.cpp:95

Scope: file

Source code excerpt:

	FConsoleVariableDelegate::CreateStatic(&CVarVRSImagePassTypeCallback),
	ECVF_RenderThreadSafe);
TAutoConsoleVariable<int32> CVarVRSTranslucency(
	TEXT("r.VRS.Translucency"),
	1,
	TEXT("Enable VRS with translucency rendering.\n")
	TEXT("0: Disabled")
	TEXT("1: Full (default)")
	TEXT("2: Conservative"),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VariableRateShading/VariableRateShadingImageManager.cpp:769

Scope: file

Source code excerpt:

		{
			CVarByPassType[EVRSPassType::BasePass] = &CVarVRSBasePass;
			CVarByPassType[EVRSPassType::TranslucencyAll] = &CVarVRSTranslucency;
			CVarByPassType[EVRSPassType::NaniteEmitGBufferPass] = &CVarVRSNaniteEmitGBuffer;
			CVarByPassType[EVRSPassType::SSAO] = &CVarVRS_SSAO;
			CVarByPassType[EVRSPassType::SSR] = &CVarVRS_SSR;
			CVarByPassType[EVRSPassType::ReflectionEnvironmentAndSky] = &CVarVRSReflectionEnvironmentSky;
			CVarByPassType[EVRSPassType::LightFunctions] = &CVarVRSLightFunctions;
			CVarByPassType[EVRSPassType::Decals] = &CVarVRSDecals;