r.RayTracing.Transmission.SamplingTechnique
r.RayTracing.Transmission.SamplingTechnique
#Overview
name: r.RayTracing.Transmission.SamplingTechnique
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0: Uses constant tracking of an infinite homogeneous medium\n1: Uses constant tracking of a finite homogeneous medium whose extent is determined by transmission sampling distance (default)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.Transmission.SamplingTechnique is to control the sampling technique used for ray tracing transmission in Unreal Engine 5’s rendering system. This variable is specifically related to the ray tracing shadows functionality.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the ray tracing subsystem. It’s referenced in the RayTracingShadows.cpp file, which suggests it’s crucial for handling shadows in ray-traced environments.
The value of this variable is set through a console variable (CVarRayTracingTransmissionSamplingTechnique) with a default value of 1. It allows two options: 0: Uses constant tracking of an infinite homogeneous medium 1: Uses constant tracking of a finite homogeneous medium whose extent is determined by transmission sampling distance (default)
This variable interacts directly with other ray tracing parameters, particularly those related to transmission sampling. It’s used in conjunction with other variables like CVarRayTracingTransmissionSamplingDistanceCulling and CVarRayTracingTransmissionRejectionSamplingTrials.
Developers must be aware that changing this variable will affect how ray-traced shadows are calculated, particularly in scenes with translucent or transmissive materials. The choice between an infinite or finite medium can impact both performance and visual accuracy.
Best practices when using this variable include:
- Understanding the scene requirements - use the infinite medium (0) for scenes with large, uniform transmissive areas, and the finite medium (1) for more varied or limited transmissive elements.
- Balancing performance and quality - the finite medium approach may offer better performance in many cases but might require more tuning with the transmission sampling distance.
- Testing both options in your specific scenes to determine which provides the best balance of performance and visual quality.
Regarding the associated variable CVarRayTracingTransmissionSamplingTechnique:
This is the actual console variable that controls the r.RayTracing.Transmission.SamplingTechnique setting. It’s defined as a TAutoConsoleVariable
The purpose of CVarRayTracingTransmissionSamplingTechnique is to provide a way to dynamically adjust the transmission sampling technique during development or gameplay.
This variable is used in the Renderer module, specifically in the ray tracing shadows system. Its value is retrieved using the GetValueOnRenderThread() method, ensuring thread-safe access in the render thread.
The value of this variable is set when it’s declared, but it can be changed at runtime through the Unreal Engine console.
This variable directly controls the TransmissionSamplingTechnique parameter in the CommonPassParameters struct, which is likely used in the ray tracing shader code.
Developers should be aware that changing this variable at runtime will immediately affect the ray tracing behavior, which could cause visual changes in the rendered scene.
Best practices for using this variable include:
- Using it for debugging and performance optimization during development.
- Potentially exposing it as a graphics option for end-users if the visual difference is significant and valuable for different hardware configurations.
- Monitoring its performance impact in various scenes and on different hardware to make informed decisions about the default value.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingShadows.cpp:59
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRayTracingTransmissionSamplingTechnique(
TEXT("r.RayTracing.Transmission.SamplingTechnique"),
1,
TEXT("0: Uses constant tracking of an infinite homogeneous medium\n")
TEXT("1: Uses constant tracking of a finite homogeneous medium whose extent is determined by transmission sampling distance (default)"),
ECVF_RenderThreadSafe
);
#Associated Variable and Callsites
This variable is associated with another variable named CVarRayTracingTransmissionSamplingTechnique
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingShadows.cpp:58
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarRayTracingTransmissionSamplingTechnique(
TEXT("r.RayTracing.Transmission.SamplingTechnique"),
1,
TEXT("0: Uses constant tracking of an infinite homogeneous medium\n")
TEXT("1: Uses constant tracking of a finite homogeneous medium whose extent is determined by transmission sampling distance (default)"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingShadows.cpp:426
Scope: file
Source code excerpt:
CommonPassParameters->PixelOffset = PixelOffset;
CommonPassParameters->bTransmissionSamplingDistanceCulling = CVarRayTracingTransmissionSamplingDistanceCulling.GetValueOnRenderThread();
CommonPassParameters->TransmissionSamplingTechnique = CVarRayTracingTransmissionSamplingTechnique.GetValueOnRenderThread();
CommonPassParameters->TransmissionMeanFreePathType = GetRayTracingTransmissionMeanFreePathType();
CommonPassParameters->RejectionSamplingTrials = CVarRayTracingTransmissionRejectionSamplingTrials.GetValueOnRenderThread();
CommonPassParameters->Substrate = Substrate::BindSubstrateGlobalUniformParameters(View);
if (bUseHairLighting)
{