r.LumenScene.DirectLighting.Heightfield.ShadowRayBias
r.LumenScene.DirectLighting.Heightfield.ShadowRayBias
#Overview
name: r.LumenScene.DirectLighting.Heightfield.ShadowRayBias
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Bias for tracing heightfield shadow rays.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.LumenScene.DirectLighting.Heightfield.ShadowRayBias is to control the bias for tracing heightfield shadow rays in Unreal Engine 5’s Lumen lighting system. This setting variable is part of the rendering system, specifically for the Lumen global illumination and reflection system.
This setting variable is primarily used in the Lumen Scene Direct Lighting subsystem of Unreal Engine 5. Based on the callsites, it’s clear that this variable is utilized within the Renderer module, particularly in the Lumen-related components.
The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 2.0f, but can be changed at runtime or through configuration files.
The associated variable CVarLumenDirectLightingHeightfieldShadowRayBias directly interacts with this setting. It’s the actual console variable object that stores and provides access to the value set by r.LumenScene.DirectLighting.Heightfield.ShadowRayBias.
Developers must be aware that this variable affects the accuracy and performance of shadow rendering in Lumen’s direct lighting calculations for heightfields. A higher bias value can help reduce shadow acne (self-shadowing artifacts) but may also cause some shadow detachment.
Best practices when using this variable include:
- Adjusting it carefully to balance between shadow quality and performance.
- Testing different values in various lighting scenarios to find the optimal setting for your specific game or application.
- Considering the impact on different hardware configurations, as the optimal value might vary based on the target platform.
Regarding the associated variable CVarLumenDirectLightingHeightfieldShadowRayBias:
Its purpose is to provide a programmatic interface to access and modify the r.LumenScene.DirectLighting.Heightfield.ShadowRayBias value within the C++ code of the engine.
This variable is used in the LumenSceneDirectLighting class, specifically in the GetHeightfieldShadowRayBias() method. This method retrieves the current value of the variable, ensuring it’s not negative.
The value of this variable is set through the console variable system, mirroring the r.LumenScene.DirectLighting.Heightfield.ShadowRayBias setting.
Developers should be aware that this variable is marked with ECVF_Scalability and ECVF_RenderThreadSafe flags, indicating that it can be adjusted for different scalability settings and is safe to access from the render thread.
Best practices for using this variable include:
- Accessing it through the provided GetHeightfieldShadowRayBias() method rather than directly.
- Being mindful of potential performance implications when frequently querying or changing this value.
- Considering caching the value if it’s accessed frequently in performance-critical code paths.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneDirectLighting.cpp:59
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarLumenDirectLightingHeightfieldShadowRayBias(
TEXT("r.LumenScene.DirectLighting.Heightfield.ShadowRayBias"),
2.0f,
TEXT("Bias for tracing heightfield shadow rays."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarLumenDirectLightingGlobalSDFShadowRayBias(
#Associated Variable and Callsites
This variable is associated with another variable named CVarLumenDirectLightingHeightfieldShadowRayBias
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneDirectLighting.cpp:58
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<float> CVarLumenDirectLightingHeightfieldShadowRayBias(
TEXT("r.LumenScene.DirectLighting.Heightfield.ShadowRayBias"),
2.0f,
TEXT("Bias for tracing heightfield shadow rays."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneDirectLighting.cpp:92
Scope (from outer to inner):
file
function float LumenSceneDirectLighting::GetHeightfieldShadowRayBias
Source code excerpt:
float LumenSceneDirectLighting::GetHeightfieldShadowRayBias()
{
return FMath::Max(CVarLumenDirectLightingHeightfieldShadowRayBias.GetValueOnRenderThread(), 0.0f);
}
float LumenSceneDirectLighting::GetGlobalSDFShadowRayBias()
{
return FMath::Max(CVarLumenDirectLightingGlobalSDFShadowRayBias.GetValueOnRenderThread(), 0.0f);
}