r.PathTracing.VisibleLights
r.PathTracing.VisibleLights
#Overview
name: r.PathTracing.VisibleLights
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Should light sources be visible to camera rays? (default = 0 (off))\n0: Hide lights from camera rays (default)\n1: Make all lights visible to camera\n2: Make skydome only visible to camera\n
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.PathTracing.VisibleLights is to control the visibility of light sources to camera rays in path tracing rendering. This setting variable is part of the rendering system, specifically for 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 where the variable is defined and used: Engine/Source/Runtime/Renderer/Private/PathTracing.cpp
.
The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with three possible values: 0: Hide lights from camera rays (default) 1: Make all lights visible to camera 2: Make skydome only visible to camera
This variable interacts with the associated variable CVarPathTracingVisibleLights, which is the actual console variable used to access and modify the setting at runtime.
Developers must be aware that this variable affects the visual output of path-traced renders. Changing this value can significantly impact the appearance of scenes, especially when dealing with visible light sources or skyboxes.
Best practices when using this variable include:
- Use the default value (0) for most standard rendering scenarios.
- Set to 1 when you want to visualize light sources directly in the scene, which can be useful for artistic or debugging purposes.
- Use value 2 when you want to isolate the skydome visibility, which can be helpful for environment lighting adjustments.
Regarding the associated variable CVarPathTracingVisibleLights: This is the actual console variable that controls the r.PathTracing.VisibleLights setting. It’s used throughout the code to retrieve the current value of the setting (e.g., CVarPathTracingVisibleLights.GetValueOnRenderThread()). Developers should use this variable when they need to programmatically check or modify the visible lights setting in their C++ code.
When working with CVarPathTracingVisibleLights, developers should:
- Use the GetValueOnRenderThread() method to safely access the current value.
- Be aware that changes to this variable will affect the rendering output in real-time.
- Consider the performance implications of making all lights visible (value 1), as it may increase rendering complexity.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:140
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarPathTracingVisibleLights(
TEXT("r.PathTracing.VisibleLights"),
0,
TEXT("Should light sources be visible to camera rays? (default = 0 (off))\n")
TEXT("0: Hide lights from camera rays (default)\n")
TEXT("1: Make all lights visible to camera\n")
TEXT("2: Make skydome only visible to camera\n"),
ECVF_RenderThreadSafe
#Associated Variable and Callsites
This variable is associated with another variable named CVarPathTracingVisibleLights
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:139
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarPathTracingVisibleLights(
TEXT("r.PathTracing.VisibleLights"),
0,
TEXT("Should light sources be visible to camera rays? (default = 0 (off))\n")
TEXT("0: Hide lights from camera rays (default)\n")
TEXT("1: Make all lights visible to camera\n")
TEXT("2: Make skydome only visible to camera\n"),
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:2064
Scope (from outer to inner):
file
function void SetLightParameters
Source code excerpt:
DestLight.IESAtlasIndex = INDEX_NONE;
DestLight.MissShaderIndex = 0;
if ((Scene->SkyLight->bRealTimeCaptureEnabled && (View.SkyAtmosphereUniformShaderParameters == nullptr || !IsSkyAtmosphereHoldout(View.CachedViewUniformShaderParameters->EnvironmentComponentsFlags))) || CVarPathTracingVisibleLights.GetValueOnRenderThread() == 2)
{
// When using the realtime capture system, always make the skylight visible
// because this is our only way of "seeing" the atmo/clouds at the moment
// The one exception to this case is if the sky atmo has been marked as holdout.
// Also allow seeing just the sky via a cvar for debugging purposes
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:2258
Scope (from outer to inner):
file
function void SetLightParameters
Source code excerpt:
}
if (CVarPathTracingVisibleLights.GetValueOnRenderThread() == 1)
{
// make all lights in the scene visible
PassParameters->SceneVisibleLightCount = PassParameters->SceneLightCount;
}
PrepareLightGrid(GraphBuilder, View.FeatureLevel, &PassParameters->LightGridParameters, Lights, NumLights, NumInfiniteLights, PassParameters->SceneLights);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:2508
Scope: file
Source code excerpt:
PreparePathTracingData(Scene, View, Config.PathTracingData);
Config.VisibleLights = CVarPathTracingVisibleLights.GetValueOnRenderThread() != 0;
Config.UseMISCompensation = Config.PathTracingData.MISMode == 2 && CVarPathTracingMISCompensation.GetValueOnRenderThread() != 0;
Config.ViewRect = View.ViewRect;
Config.LightGridResolution = FMath::RoundUpToPowerOfTwo(CVarPathTracingLightGridResolution.GetValueOnRenderThread());
Config.LightGridMaxCount = FMath::Clamp(CVarPathTracingLightGridMaxCount.GetValueOnRenderThread(), 1, RAY_TRACING_LIGHT_COUNT_MAXIMUM);