r.TranslucencyLightingVolumeInnerDistance
r.TranslucencyLightingVolumeInnerDistance
#Overview
name: r.TranslucencyLightingVolumeInnerDistance
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Distance from the camera that the first volume cascade should end
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.TranslucencyLightingVolumeInnerDistance is to control the distance from the camera at which the first volume cascade for translucency lighting should end. This setting is part of Unreal Engine’s rendering system, specifically related to the translucent lighting volume feature.
This setting variable is primarily used in the Renderer module of Unreal Engine, as evidenced by its location in the TranslucentLighting.cpp file. It’s an important part of the translucency lighting system, which is responsible for rendering realistic lighting effects on translucent objects.
The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 1500.0f, but can be changed at runtime through console commands or project settings.
This variable interacts closely with another variable called r.TranslucencyLightingVolumeOuterDistance, which defines the outer distance of the translucency lighting volume. Together, these two variables define the range of the translucency lighting volume.
Developers must be aware that this variable directly affects the quality and performance of translucent lighting in their scenes. A smaller value will result in higher quality lighting for nearby translucent objects but may impact performance, while a larger value will extend the high-quality lighting further from the camera at the cost of potential performance impact.
Best practices when using this variable include:
- Balancing it with r.TranslucencyLightingVolumeOuterDistance for optimal quality and performance.
- Adjusting it based on the specific needs of your scene and the typical viewing distances of translucent objects.
- Testing different values to find the best trade-off between visual quality and performance for your specific project.
Regarding the associated variable CVarTranslucencyLightingVolumeInnerDistance:
This is the actual console variable that stores and manages the r.TranslucencyLightingVolumeInnerDistance value. It’s defined using the TAutoConsoleVariable template, which is part of Unreal Engine’s console variable system.
The purpose of this variable is the same as r.TranslucencyLightingVolumeInnerDistance - to control the inner distance of the translucency lighting volume.
This variable is used directly in the renderer code to calculate the bounds of the translucency lighting volume. It’s accessed using the GetValueOnRenderThread() method, ensuring thread-safe access to the value.
Developers should be aware that changes to this variable will take effect on the render thread, which means there might be a slight delay before changes are visible in the scene.
Best practices for using this variable include:
- Modifying it through the appropriate engine interfaces rather than directly manipulating the CVarTranslucencyLightingVolumeInnerDistance object.
- Being cautious when changing its value at runtime, as it can affect rendering performance and quality.
- Considering its interaction with CVarTranslucencyLightingVolumeOuterDistance when making adjustments.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentLighting.cpp:103
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarTranslucencyLightingVolumeInnerDistance(
TEXT("r.TranslucencyLightingVolumeInnerDistance"),
1500.0f,
TEXT("Distance from the camera that the first volume cascade should end"),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarTranslucencyLightingVolumeOuterDistance(
TEXT("r.TranslucencyLightingVolumeOuterDistance"),
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentLighting.cpp:186
Scope (from outer to inner):
file
function void FViewInfo::CalcTranslucencyLightingVolumeBounds
Source code excerpt:
}
if (RadiusSquared > 0) // Avoid issues with bad cvar usage, e.g. r.TranslucencyLightingVolumeInnerDistance.
{
FSphere SphereBounds(Center, FMath::Sqrt(RadiusSquared));
// Snap the center to a multiple of the volume dimension for stability
const int32 TranslucencyLightingVolumeDim = GetTranslucencyLightingVolumeDim();
SphereBounds.Center.X = SphereBounds.Center.X - FMath::Fmod(SphereBounds.Center.X, SphereBounds.W * 2 / TranslucencyLightingVolumeDim);
#Associated Variable and Callsites
This variable is associated with another variable named CVarTranslucencyLightingVolumeInnerDistance
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentLighting.cpp:102
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<float> CVarTranslucencyLightingVolumeInnerDistance(
TEXT("r.TranslucencyLightingVolumeInnerDistance"),
1500.0f,
TEXT("Distance from the camera that the first volume cascade should end"),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarTranslucencyLightingVolumeOuterDistance(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentLighting.cpp:125
Scope (from outer to inner):
file
function void FViewInfo::CalcTranslucencyLightingVolumeBounds
Source code excerpt:
for (int32 CascadeIndex = 0; CascadeIndex < NumCascades; CascadeIndex++)
{
double InnerDistance = CVarTranslucencyLightingVolumeInnerDistance.GetValueOnRenderThread();
double OuterDistance = CVarTranslucencyLightingVolumeOuterDistance.GetValueOnRenderThread();
const double FrustumStartDistance = CascadeIndex == 0 ? 0 : InnerDistance;
const double FrustumEndDistance = CascadeIndex == 0 ? InnerDistance : OuterDistance;
double FieldOfView = DOUBLE_PI / 4.0;