r.LumenScene.DirectLighting.MeshSDF.ShadowRayBias

r.LumenScene.DirectLighting.MeshSDF.ShadowRayBias

#Overview

name: r.LumenScene.DirectLighting.MeshSDF.ShadowRayBias

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.LumenScene.DirectLighting.MeshSDF.ShadowRayBias is to control the bias for tracing mesh SDF (Signed Distance Field) shadow rays in Lumen’s direct lighting system. This setting is part of Unreal Engine 5’s Lumen global illumination system, specifically for the rendering of direct lighting and shadows.

This setting variable is primarily used by the Lumen scene direct lighting subsystem within the Renderer module of Unreal Engine 5. It’s specifically related to the mesh SDF shadow tracing functionality of Lumen.

The value of this variable is set through the console variable system, with a default value of 2.0f. It can be modified at runtime using console commands or through configuration files.

This variable interacts directly with its associated C++ variable CVarLumenDirectLightingMeshSDFShadowRayBias. The GetMeshSDFShadowRayBias() function in the LumenSceneDirectLighting class uses this variable to retrieve the current bias value.

Developers should be aware that this variable affects the accuracy and appearance of shadows in scenes using Lumen’s direct lighting. A higher bias value may help prevent shadow acne (self-shadowing artifacts) but might also cause some shadow detachment.

Best practices when using this variable include:

  1. Adjusting it carefully to balance between shadow quality and performance.
  2. Testing different values in various lighting scenarios to ensure consistent results.
  3. Considering the scale of your scene, as larger scenes might require different bias values.
  4. Using it in conjunction with other Lumen settings for optimal results.

Regarding the associated variable CVarLumenDirectLightingMeshSDFShadowRayBias:

The purpose of CVarLumenDirectLightingMeshSDFShadowRayBias is to provide a C++ interface for the r.LumenScene.DirectLighting.MeshSDF.ShadowRayBias console variable. It allows the engine to access and modify the shadow ray bias value programmatically.

This variable is used within the Renderer module, specifically in the Lumen scene direct lighting system. It’s accessed through the GetValueOnRenderThread() method, which ensures thread-safe access to the current value.

The value of this variable is set when the console variable is initialized, and it can be modified at runtime through the console variable system.

CVarLumenDirectLightingMeshSDFShadowRayBias interacts directly with the console variable system and is used by the GetMeshSDFShadowRayBias() function to retrieve the current bias value.

Developers should be aware that this variable is marked with ECVF_Scalability and ECVF_RenderThreadSafe flags, indicating that it can affect performance scaling and is safe to access from the render thread.

Best practices for using this variable include:

  1. Accessing it through the provided GetMeshSDFShadowRayBias() function rather than directly.
  2. Being mindful of potential performance implications when modifying this value frequently.
  3. Ensuring any modifications are made in a thread-safe manner, respecting the ECVF_RenderThreadSafe flag.

#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:52

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarLumenDirectLightingMeshSDFShadowRayBias(
	TEXT("r.LumenScene.DirectLighting.MeshSDF.ShadowRayBias"),
	2.0f,
	TEXT("Bias for tracing mesh SDF shadow rays."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<float> CVarLumenDirectLightingHeightfieldShadowRayBias(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneDirectLighting.cpp:51

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<float> CVarLumenDirectLightingMeshSDFShadowRayBias(
	TEXT("r.LumenScene.DirectLighting.MeshSDF.ShadowRayBias"),
	2.0f,
	TEXT("Bias for tracing mesh SDF shadow rays."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneDirectLighting.cpp:87

Scope (from outer to inner):

file
function     float LumenSceneDirectLighting::GetMeshSDFShadowRayBias

Source code excerpt:

float LumenSceneDirectLighting::GetMeshSDFShadowRayBias()
{
	return FMath::Max(CVarLumenDirectLightingMeshSDFShadowRayBias.GetValueOnRenderThread(), 0.0f);
}

float LumenSceneDirectLighting::GetHeightfieldShadowRayBias()
{
	return FMath::Max(CVarLumenDirectLightingHeightfieldShadowRayBias.GetValueOnRenderThread(), 0.0f);
}