r.HeterogeneousVolumes.CompositeWithTranslucency.Refraction.TransmittanceThreshold
r.HeterogeneousVolumes.CompositeWithTranslucency.Refraction.TransmittanceThreshold
#Overview
name: r.HeterogeneousVolumes.CompositeWithTranslucency.Refraction.TransmittanceThreshold
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Minimum transmittance threshold to apply distortion (Default = 0.9)\nRequires enabling Heterogeneous Volumes Project Setting: \'Composite with Translucency\'
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.HeterogeneousVolumes.CompositeWithTranslucency.Refraction.TransmittanceThreshold is to set a minimum transmittance threshold for applying distortion effects in the rendering of heterogeneous volumes. This setting is specifically related to the refraction component of the rendering system when compositing with translucency.
This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically within the distortion rendering subsystem. It is defined and used in the DistortionRendering.cpp file.
The value of this variable is set through a console variable (CVar) system, with a default value of 0.9. It can be adjusted at runtime using console commands or through engine configuration files.
This variable interacts closely with its associated variable CVarRefractionTransmittanceThreshold. They share the same value and are used interchangeably in the code.
Developers must be aware that this setting only takes effect when the Heterogeneous Volumes Project Setting ‘Composite with Translucency’ is enabled. The value is clamped between 0.0 and 1.0 when used in calculations.
Best practices when using this variable include:
- Adjusting it carefully to balance visual quality and performance.
- Testing different values to find the optimal threshold for your specific scene and desired visual effect.
- Ensuring that the ‘Composite with Translucency’ setting is enabled in the project settings when intending to use this feature.
Regarding the associated variable CVarRefractionTransmittanceThreshold:
The purpose of CVarRefractionTransmittanceThreshold is to provide a programmatic way to access and modify the refraction transmittance threshold value. It is used internally by the engine to retrieve the current value of the setting when needed for calculations in the distortion rendering process.
This associated variable is used in the same Renderer module and distortion rendering subsystem as the main setting variable. It is typically used to get the current value of the setting on the render thread.
The value of CVarRefractionTransmittanceThreshold is set automatically when the r.HeterogeneousVolumes.CompositeWithTranslucency.Refraction.TransmittanceThreshold console variable is modified.
CVarRefractionTransmittanceThreshold interacts directly with the main setting variable, effectively serving as its in-code representation.
Developers should be aware that this variable is designed for internal engine use and should generally not be modified directly. Instead, changes should be made through the main console variable.
Best practices for CVarRefractionTransmittanceThreshold include:
- Using it to retrieve the current transmittance threshold value in C++ code when needed.
- Avoiding direct modification of this variable, instead using the console variable system to change the value.
- Being aware of potential thread safety issues, as it’s accessed on the render thread.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistortionRendering.cpp:66
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarRefractionTransmittanceThreshold(
TEXT("r.HeterogeneousVolumes.CompositeWithTranslucency.Refraction.TransmittanceThreshold"),
0.9,
TEXT("Minimum transmittance threshold to apply distortion (Default = 0.9)\n")
TEXT("Requires enabling Heterogeneous Volumes Project Setting: 'Composite with Translucency'"),
ECVF_RenderThreadSafe);
BEGIN_GLOBAL_SHADER_PARAMETER_STRUCT(FDistortionPassUniformParameters, RENDERER_API)
#Associated Variable and Callsites
This variable is associated with another variable named CVarRefractionTransmittanceThreshold
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistortionRendering.cpp:65
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarRefractionTransmittanceThreshold(
TEXT("r.HeterogeneousVolumes.CompositeWithTranslucency.Refraction.TransmittanceThreshold"),
0.9,
TEXT("Minimum transmittance threshold to apply distortion (Default = 0.9)\n")
TEXT("Requires enabling Heterogeneous Volumes Project Setting: 'Composite with Translucency'"),
ECVF_RenderThreadSafe);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistortionRendering.cpp:130
Scope (from outer to inner):
file
function TRDGUniformBufferRef<FDistortionPassUniformParameters> CreateDistortionPassUniformBuffer
Source code excerpt:
Parameters->AVSM = HeterogeneousVolumes::GetAdaptiveVolumetricCameraMapParameters(GraphBuilder, View.ViewState);
Parameters->UseAVSM = CVarRefractionUseAVSM.GetValueOnRenderThread() != 0;
Parameters->TransmittanceThreshold = FMath::Clamp(CVarRefractionTransmittanceThreshold.GetValueOnRenderThread(), 0.0, 1.0);
return GraphBuilder.CreateUniformBuffer(Parameters);
}
static bool GetUseRoughRefraction()
{