r.RayTracing.Translucency
r.RayTracing.Translucency
#Overview
name: r.RayTracing.Translucency
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
-1: Value driven by postprocess volume (default) \n 0: ray tracing translucency off (use raster) \n 1: ray tracing translucency enabled
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.Translucency is to control the ray tracing translucency feature in Unreal Engine’s rendering system. This setting variable is part of the ray tracing subsystem and is used to enable or disable ray-traced translucency effects.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the ray tracing subsystem. It’s referenced in the RayTracingTranslucency.cpp file, which suggests it’s crucial for handling translucent objects in ray-traced scenes.
The value of this variable is set through a console variable (CVarRayTracingTranslucency). It can be set to three different values:
- -1: The value is driven by the post-process volume (default)
- 0: Ray tracing translucency is off (uses raster instead)
- 1: Ray tracing translucency is enabled
The variable interacts with the View’s FinalPostProcessSettings, specifically the TranslucencyType property. It’s used in conjunction with this setting to determine whether ray-traced translucency should be rendered.
Developers should be aware that this variable can significantly impact rendering performance and visual quality. Enabling ray-traced translucency can provide more accurate and realistic translucent effects but at the cost of increased computational requirements.
Best practices when using this variable include:
- Use the default value (-1) to allow for dynamic control through post-process volumes.
- Consider performance implications when enabling ray-traced translucency, especially on lower-end hardware.
- Test the visual impact and performance with and without ray-traced translucency to find the best balance for your project.
Regarding the associated variable CVarRayTracingTranslucency:
This is the actual console variable that controls the r.RayTracing.Translucency setting. It’s defined as a TAutoConsoleVariable
The purpose of CVarRayTracingTranslucency is to provide a programmable interface to control the ray tracing translucency feature. It’s used in the ShouldRenderRayTracingTranslucency function to determine whether ray-traced translucency should be rendered for a given view.
This variable is set in the same file where it’s defined (RayTracingTranslucency.cpp). Its value can be accessed on the render thread using the GetValueOnRenderThread() method.
Developers should be aware that changes to this variable will take effect on the render thread, which means there might be a slight delay between changing the value and seeing the results in the rendered scene.
Best practices for using CVarRayTracingTranslucency include:
- Use it for debugging or performance testing purposes.
- Be cautious when changing its value at runtime, as it can affect rendering performance.
- Consider exposing this setting in your game’s graphics options menu to allow users to control ray-traced translucency based on their hardware capabilities.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingTranslucency.cpp:21
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRayTracingTranslucency(
TEXT("r.RayTracing.Translucency"),
-1,
TEXT("-1: Value driven by postprocess volume (default) \n")
TEXT(" 0: ray tracing translucency off (use raster) \n")
TEXT(" 1: ray tracing translucency enabled"),
ECVF_RenderThreadSafe | ECVF_Scalability);
#Associated Variable and Callsites
This variable is associated with another variable named CVarRayTracingTranslucency
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingTranslucency.cpp:20
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRayTracingTranslucency(
TEXT("r.RayTracing.Translucency"),
-1,
TEXT("-1: Value driven by postprocess volume (default) \n")
TEXT(" 0: ray tracing translucency off (use raster) \n")
TEXT(" 1: ray tracing translucency enabled"),
ECVF_RenderThreadSafe | ECVF_Scalability);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingTranslucency.cpp:132
Scope (from outer to inner):
file
function bool ShouldRenderRayTracingTranslucency
Source code excerpt:
const bool bViewWithRaytracingTranslucency = View.FinalPostProcessSettings.TranslucencyType == ETranslucencyType::RayTracing;
const int32 RayTracingTranslucencyMode = CVarRayTracingTranslucency.GetValueOnRenderThread();
const bool bTranslucencyEnabled = RayTracingTranslucencyMode < 0
? bViewWithRaytracingTranslucency
: RayTracingTranslucencyMode != 0;
return ShouldRenderRayTracingEffect(bTranslucencyEnabled, ERayTracingPipelineCompatibilityFlags::FullPipeline, &View);