r.PathTracing.LightFunctionColor
r.PathTracing.LightFunctionColor
#Overview
name: r.PathTracing.LightFunctionColor
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables light functions to be colored instead of greyscale (default = 0)\n0: off (default)\n1: on (light function material output is used directly instead of converting to greyscale)\n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.PathTracing.LightFunctionColor is to control whether light functions in path tracing are rendered in color or grayscale. This setting variable is part of the rendering system, specifically the path tracing subsystem in Unreal Engine 5.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the path tracing component. This can be seen from the file location “Engine/Source/Runtime/Renderer/Private/PathTracing.cpp” where the variable is defined and used.
The value of this variable is set through a console variable (CVarPathTracingLightFunctionColor) with a default value of 0 (off). It can be changed at runtime through console commands or programmatically.
The associated variable CVarPathTracingLightFunctionColor directly interacts with r.PathTracing.LightFunctionColor. They share the same value and purpose.
Developers must be aware that:
- This variable is render thread safe, meaning it can be safely modified from different threads.
- When enabled (set to 1), light function material output is used directly instead of converting to grayscale.
- This setting can affect the visual output of path-traced scenes, particularly those using light functions.
Best practices when using this variable include:
- Use it to enhance visual fidelity in path-traced scenes where colored light functions are desired.
- Be mindful of potential performance implications when enabling colored light functions.
- Test scenes with both settings (0 and 1) to ensure the desired visual outcome.
Regarding the associated variable CVarPathTracingLightFunctionColor:
- Its purpose is identical to r.PathTracing.LightFunctionColor.
- It’s used internally in the Renderer module to control the behavior of light functions in path tracing.
- The value is retrieved using GetValueOnRenderThread() method, ensuring thread-safe access.
- It’s used to set the EnableColoredLightFunctions parameter in the light function uniform buffer and to configure light show flags for path tracing.
Developers should treat CVarPathTracingLightFunctionColor as the programmatic interface to control the r.PathTracing.LightFunctionColor setting within C++ code of the Unreal Engine.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:322
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarPathTracingLightFunctionColor(
TEXT("r.PathTracing.LightFunctionColor"),
0,
TEXT("Enables light functions to be colored instead of greyscale (default = 0)\n")
TEXT("0: off (default)\n")
TEXT("1: on (light function material output is used directly instead of converting to greyscale)\n"),
ECVF_RenderThreadSafe
);
#Associated Variable and Callsites
This variable is associated with another variable named CVarPathTracingLightFunctionColor
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:321
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarPathTracingLightFunctionColor(
TEXT("r.PathTracing.LightFunctionColor"),
0,
TEXT("Enables light functions to be colored instead of greyscale (default = 0)\n")
TEXT("0: off (default)\n")
TEXT("1: on (light function material output is used directly instead of converting to greyscale)\n"),
ECVF_RenderThreadSafe
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:1249
Scope (from outer to inner):
file
function static TUniformBufferRef<FLightFunctionParametersPathTracing> CreateLightFunctionParametersBufferPT
Source code excerpt:
bRenderingPreviewShadowIndicator ? 1.0f : 0.0f);
LightFunctionParameters.EnableColoredLightFunctions = CVarPathTracingLightFunctionColor.GetValueOnRenderThread();
return CreateUniformBufferImmediate(LightFunctionParameters, Usage);
}
// Miss Shader implementing light functions
class FPathTracingLightingMS : public FMaterialShader
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:2492
Scope: file
Source code excerpt:
Config.LightShowFlags |= View.Family->EngineShowFlags.TexturedLightProfiles ? 1 << 5 : 0;
Config.LightShowFlags |= View.Family->EngineShowFlags.LightFunctions ? 1 << 6 : 0;
Config.LightShowFlags |= CVarPathTracingLightFunctionColor.GetValueOnRenderThread() ? 1 << 7 : 0;
// the following flags all mess with diffuse/spec overrides and therefore change the image
Config.LightShowFlags |= View.Family->EngineShowFlags.Diffuse ? 1 << 8 : 0;
Config.LightShowFlags |= View.Family->EngineShowFlags.Specular ? 1 << 9 : 0;
Config.LightShowFlags |= View.Family->EngineShowFlags.OverrideDiffuseAndSpecular ? 1 << 10 : 0;
Config.LightShowFlags |= View.Family->EngineShowFlags.LightingOnlyOverride ? 1 << 11 : 0;
Config.LightShowFlags |= View.Family->EngineShowFlags.ReflectionOverride ? 1 << 12 : 0;