r.PathTracing.LightFunctionColor

r.PathTracing.LightFunctionColor

#Overview

name: r.PathTracing.LightFunctionColor

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

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:

  1. This variable is render thread safe, meaning it can be safely modified from different threads.
  2. When enabled (set to 1), light function material output is used directly instead of converting to grayscale.
  3. This setting can affect the visual output of path-traced scenes, particularly those using light functions.

Best practices when using this variable include:

  1. Use it to enhance visual fidelity in path-traced scenes where colored light functions are desired.
  2. Be mindful of potential performance implications when enabling colored light functions.
  3. Test scenes with both settings (0 and 1) to ensure the desired visual outcome.

Regarding the associated variable CVarPathTracingLightFunctionColor:

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;