r.Lumen.HardwareRayTracing.SkipBackFaceHitDistance

r.Lumen.HardwareRayTracing.SkipBackFaceHitDistance

#Overview

name: r.Lumen.HardwareRayTracing.SkipBackFaceHitDistance

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.Lumen.HardwareRayTracing.SkipBackFaceHitDistance is to control the distance for ray tracing with backface culling enabled in Lumen’s hardware ray tracing system. It’s specifically designed for scenarios where the Ray Tracing geometry doesn’t match the GBuffer, such as when using Nanite Proxy geometry.

This setting variable is primarily used in the Lumen subsystem of Unreal Engine’s rendering module. Based on the callsites, it’s clear that this variable is utilized in the hardware ray tracing component of Lumen, which is part of the engine’s global illumination and reflection system.

The value of this variable is set through the console variable system, as evidenced by the TAutoConsoleVariable declaration. It can be modified at runtime or set in configuration files.

The associated variable CVarLumenHardwareRayTracingSkipBackFaceHitDistance directly interacts with r.Lumen.HardwareRayTracing.SkipBackFaceHitDistance. They share the same value and purpose.

Developers must be aware that this variable affects the accuracy and performance of ray tracing in scenarios where there’s a mismatch between ray tracing geometry and the GBuffer. Adjusting this value can help mitigate artifacts or improve performance in such cases.

Best practices when using this variable include:

  1. Fine-tuning the value based on the specific geometry in your scene, especially when using Nanite.
  2. Monitoring performance impacts when adjusting this value, as it can affect ray tracing efficiency.
  3. Using it in conjunction with other Lumen settings for optimal results.

Regarding the associated variable CVarLumenHardwareRayTracingSkipBackFaceHitDistance:

The purpose of CVarLumenHardwareRayTracingSkipBackFaceHitDistance is identical to r.Lumen.HardwareRayTracing.SkipBackFaceHitDistance. It’s the internal representation of the console variable in the C++ code.

This variable is used in the Lumen subsystem of the rendering module, specifically in the hardware ray tracing component.

The value is set when the console variable is initialized, with a default value of 5.0f. It can be accessed and potentially modified at runtime using the GetValueOnRenderThread() method.

CVarLumenHardwareRayTracingSkipBackFaceHitDistance directly interacts with the uniform buffer parameters for Lumen hardware ray tracing, as seen in the SetupLumenHardwareRayTracingUniformBuffer function.

Developers should be aware that this is the actual variable used in the code, and any runtime changes to the console variable will be reflected through this variable.

Best practices include using the appropriate methods to access this variable’s value, such as GetValueOnRenderThread(), to ensure thread-safe operations in the rendering pipeline.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenHardwareRayTracingMaterials.cpp:18

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarLumenHardwareRayTracingSkipBackFaceHitDistance(
	TEXT("r.Lumen.HardwareRayTracing.SkipBackFaceHitDistance"),
	5.0f,
	TEXT("Distance to trace with backface culling enabled, useful when the Ray Tracing geometry doesn't match the GBuffer (Nanite Proxy geometry)."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<float> CVarLumenHardwareRayTracingSkipTwoSidedHitDistance(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenHardwareRayTracingMaterials.cpp:17

Scope: file

Source code excerpt:

#include "Lumen/LumenReflections.h"

static TAutoConsoleVariable<float> CVarLumenHardwareRayTracingSkipBackFaceHitDistance(
	TEXT("r.Lumen.HardwareRayTracing.SkipBackFaceHitDistance"),
	5.0f,
	TEXT("Distance to trace with backface culling enabled, useful when the Ray Tracing geometry doesn't match the GBuffer (Nanite Proxy geometry)."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenHardwareRayTracingMaterials.cpp:116

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::SetupLumenHardwareRayTracingUniformBuffer

Source code excerpt:

{
	FLumenHardwareRayTracingUniformBufferParameters* LumenHardwareRayTracingUniformBufferParameters = GraphBuilder.AllocParameters<FLumenHardwareRayTracingUniformBufferParameters>();
	LumenHardwareRayTracingUniformBufferParameters->SkipBackFaceHitDistance = CVarLumenHardwareRayTracingSkipBackFaceHitDistance.GetValueOnRenderThread();
	LumenHardwareRayTracingUniformBufferParameters->SkipTwoSidedHitDistance = CVarLumenHardwareRayTracingSkipTwoSidedHitDistance.GetValueOnRenderThread();
	LumenHardwareRayTracingUniformBufferParameters->SkipTranslucent         = LumenReflections::UseTranslucentRayTracing(View) ? 0.0f : 1.0f;
	View.LumenHardwareRayTracingUniformBuffer = GraphBuilder.CreateUniformBuffer(LumenHardwareRayTracingUniformBufferParameters);
}

uint32 CalculateLumenHardwareRayTracingUserData(const FRayTracingMeshCommand& MeshCommand)