r.Shadow.PointLightSlopeScaleDepthBias
r.Shadow.PointLightSlopeScaleDepthBias
#Overview
name: r.Shadow.PointLightSlopeScaleDepthBias
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Slope scale depth bias that is applied in the depth pass for shadows from point lights
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.PointLightSlopeScaleDepthBias is to control the slope scale depth bias applied in the depth pass for shadows from point lights in Unreal Engine 5’s rendering system.
This setting variable is primarily used by the rendering subsystem, specifically for shadow rendering from point lights. It’s part of the shadow rendering module within the engine.
The value of this variable is set as a console variable with a default value of 3.0f. It can be adjusted at runtime through the console or through configuration files.
The variable interacts closely with its associated variable CVarPointLightShadowSlopeScaleDepthBias, which is defined as a TAutoConsoleVariable. This associated variable is used to actually store and retrieve the value set by r.Shadow.PointLightSlopeScaleDepthBias.
Developers should be aware that this variable directly affects the visual quality and performance of point light shadows. A higher 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 in small increments to find the optimal balance between shadow quality and performance.
- Testing the changes across various lighting scenarios to ensure consistent results.
- Considering the interaction with other shadow-related settings for a holistic approach to shadow quality.
Regarding the associated variable CVarPointLightShadowSlopeScaleDepthBias:
The purpose of CVarPointLightShadowSlopeScaleDepthBias is to provide a programmatic interface to access and modify the r.Shadow.PointLightSlopeScaleDepthBias value within the C++ code of the engine.
This variable is used directly in the rendering subsystem, specifically in the ShadowRendering.cpp file. It’s part of the core rendering module of Unreal Engine 5.
The value of this variable is set when r.Shadow.PointLightSlopeScaleDepthBias is modified, as they share the same value.
CVarPointLightShadowSlopeScaleDepthBias interacts with other shadow rendering variables and is used in calculations for shadow depth bias.
Developers should be aware that this variable is accessed on the render thread, as indicated by the GetValueOnRenderThread() method used in the code.
Best practices when using this variable include:
- Ensuring thread-safe access when reading or modifying its value.
- Understanding its impact on the overall shadow rendering pipeline before making changes.
- Using it in conjunction with other shadow-related variables for comprehensive shadow quality control.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:84
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarPointLightShadowSlopeScaleDepthBias(
TEXT("r.Shadow.PointLightSlopeScaleDepthBias"),
3.0f,
TEXT("Slope scale depth bias that is applied in the depth pass for shadows from point lights"),
ECVF_RenderThreadSafe);
///////////////////////////////////////////////////////////////////////////////////////////////////
#Associated Variable and Callsites
This variable is associated with another variable named CVarPointLightShadowSlopeScaleDepthBias
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:83
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarPointLightShadowSlopeScaleDepthBias(
TEXT("r.Shadow.PointLightSlopeScaleDepthBias"),
3.0f,
TEXT("Slope scale depth bias that is applied in the depth pass for shadows from point lights"),
ECVF_RenderThreadSafe);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:1826
Scope (from outer to inner):
file
function void FProjectedShadowInfo::UpdateShaderDepthBias
Source code excerpt:
{
DeptBiasConstant = CVarPointLightShadowDepthBias.GetValueOnRenderThread();
SlopeDepthBiasConstant = CVarPointLightShadowSlopeScaleDepthBias.GetValueOnRenderThread();
}
DepthBias = DeptBiasConstant * 512.0f / FMath::Max(ResolutionX, ResolutionY);
// * 2.0f to be compatible with the system we had before ShadowBias
DepthBias *= 2.0f * LightSceneInfo->Proxy->GetUserShadowBias();