r.RayTracing.LightFunction
r.RayTracing.LightFunction
#Overview
name: r.RayTracing.LightFunction
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to support light material functions in ray tracing effects. (default = 1)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.LightFunction is to control the support for light material functions in ray tracing effects within Unreal Engine 5’s rendering system.
This setting variable is primarily used by the ray tracing subsystem within the Unreal Engine’s rendering module. Specifically, it is referenced in the RayTracingLighting.cpp file, which is part of the renderer’s private implementation for ray tracing lighting.
The value of this variable is set through a console variable (CVarRayTracingLightFunction) with a default value of 1, meaning light material functions are supported by default in ray tracing effects.
The associated variable CVarRayTracingLightFunction interacts directly with r.RayTracing.LightFunction. They share the same value and purpose.
Developers must be aware that this variable affects the performance and visual fidelity of ray-traced lighting. Enabling light functions in ray tracing can increase computational overhead but may be necessary for certain visual effects.
Best practices when using this variable include:
- Only enable it when light material functions are actually needed in ray-traced scenes to optimize performance.
- Consider disabling it temporarily for performance testing or debugging ray tracing issues.
- Be aware of its impact on the overall rendering pipeline, especially in performance-critical scenarios.
Regarding the associated variable CVarRayTracingLightFunction:
- It is defined as a static TAutoConsoleVariable
, which means it’s a console variable that can be changed at runtime. - It’s used directly in the GatherLightFunctionLights function to determine whether to process light functions for ray tracing.
- Developers can modify this variable through console commands, allowing for real-time toggling of light function support in ray tracing without recompiling the engine.
- When debugging or profiling ray tracing performance, developers can easily disable light functions by setting this variable to 0 through the console.
In summary, r.RayTracing.LightFunction and its associated CVarRayTracingLightFunction provide a flexible way to control the inclusion of light material functions in ray tracing calculations, balancing visual quality with performance considerations in Unreal Engine 5’s rendering system.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingLighting.cpp:13
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRayTracingLightFunction(
TEXT("r.RayTracing.LightFunction"),
1,
TEXT("Whether to support light material functions in ray tracing effects. (default = 1)"),
ECVF_RenderThreadSafe);
TAutoConsoleVariable<int32> CVarRayTracingLightGridResolution(
TEXT("r.RayTracing.LightGridResolution"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarRayTracingLightFunction
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingLighting.cpp:12
Scope: file
Source code excerpt:
#include "RayTracingTypes.h"
static TAutoConsoleVariable<int32> CVarRayTracingLightFunction(
TEXT("r.RayTracing.LightFunction"),
1,
TEXT("Whether to support light material functions in ray tracing effects. (default = 1)"),
ECVF_RenderThreadSafe);
TAutoConsoleVariable<int32> CVarRayTracingLightGridResolution(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingLighting.cpp:521
Scope (from outer to inner):
file
function FRayTracingLightFunctionMap GatherLightFunctionLights
Source code excerpt:
// gives control over lighting functions in raytraced effects, independently of the show flag (for performance testing / debug)
if (CVarRayTracingLightFunction.GetValueOnRenderThread() == 0)
{
return {};
}
FRayTracingLightFunctionMap RayTracingLightFunctionMap;
for (const FLightSceneInfoCompact& Light : Scene->Lights)