r.Shadow.RectLightSlopeScaleDepthBias

r.Shadow.RectLightSlopeScaleDepthBias

#Overview

name: r.Shadow.RectLightSlopeScaleDepthBias

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Shadow.RectLightSlopeScaleDepthBias is to control the slope scale depth bias applied in the depth pass for shadows from rectangular lights in Unreal Engine 5’s rendering system.

This setting variable is primarily used by the rendering subsystem, specifically in the shadow rendering module. It affects how shadows are rendered for rectangular lights, which are commonly used in architectural and interior lighting scenarios.

The value of this variable is set as a console variable with a default value of 2.5f. It can be adjusted at runtime through the console or programmatically.

The associated variable CVarRectLightShadowSlopeScaleDepthBias interacts directly with r.Shadow.RectLightSlopeScaleDepthBias. They share the same value and purpose.

Developers must be aware that this variable specifically affects rectangular light shadows and not other types of light sources. Adjusting this value can help reduce shadow acne (self-shadowing artifacts) for rectangular lights, but may also affect shadow quality and performance.

Best practices when using this variable include:

  1. Adjusting it in small increments to find the optimal balance between shadow quality and artifact reduction.
  2. Testing the changes in various lighting scenarios to ensure consistent results.
  3. Considering the performance impact, as higher values may affect rendering performance.

Regarding the associated variable CVarRectLightShadowSlopeScaleDepthBias:

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:99

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarRectLightShadowSlopeScaleDepthBias(
	TEXT("r.Shadow.RectLightSlopeScaleDepthBias"),
	2.5f,
	TEXT("Slope scale depth bias that is applied in the depth pass for shadows from rect lights"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarRectLightShadowReceiverBias(
	TEXT("r.Shadow.RectLightReceiverBias"),

#Associated Variable and Callsites

This variable is associated with another variable named CVarRectLightShadowSlopeScaleDepthBias. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:98

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarRectLightShadowSlopeScaleDepthBias(
	TEXT("r.Shadow.RectLightSlopeScaleDepthBias"),
	2.5f,
	TEXT("Slope scale depth bias that is applied in the depth pass for shadows from rect lights"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarRectLightShadowReceiverBias(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:1821

Scope (from outer to inner):

file
function     void FProjectedShadowInfo::UpdateShaderDepthBias

Source code excerpt:

		{
			DeptBiasConstant = CVarRectLightShadowDepthBias.GetValueOnRenderThread();
			SlopeDepthBiasConstant = CVarRectLightShadowSlopeScaleDepthBias.GetValueOnRenderThread();
		}
		else
		{
			DeptBiasConstant = CVarPointLightShadowDepthBias.GetValueOnRenderThread();
			SlopeDepthBiasConstant = CVarPointLightShadowSlopeScaleDepthBias.GetValueOnRenderThread();
		}