r.PathTracing
r.PathTracing
#Overview
name: r.PathTracing
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables the path tracing renderer (to guard the compilation of path tracer specific material permutations)
It is referenced in 10
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.PathTracing is to enable or disable the path tracing renderer in Unreal Engine 5. It is primarily used for the rendering system, specifically for path tracing calculations.
This setting variable is relied upon by several Unreal Engine subsystems and modules:
- The main Renderer module
- The GPULightmass plugin
- The MovieRenderPipeline plugin
- The UnrealEd module
The value of this variable is set through a console variable (CVar) system. It is defined as a TAutoConsoleVariable with an initial value of 1 (enabled) in the Renderer module.
The variable interacts with another associated variable named CVarPathTracing. They share the same value and are often used interchangeably in the code.
Developers must be aware of several things when using this variable:
- It affects the compilation of path tracer-specific material permutations.
- It is read-only and render thread safe.
- It is used to determine if path tracing is supported and enabled in various parts of the engine.
- It influences the visibility of path tracing options in the editor viewport.
Best practices when using this variable include:
- Ensure that ray tracing is enabled before attempting to use path tracing.
- Check for platform support using FDataDrivenShaderPlatformInfo::GetSupportsPathTracing().
- Be aware that changing this variable may affect performance and rendering quality.
Regarding the associated variable CVarPathTracing:
The purpose of CVarPathTracing is the same as r.PathTracing - to control the path tracing renderer. It is defined in the Renderer module and is used internally by the engine to check the state of path tracing.
CVarPathTracing is used in various parts of the engine to determine if path tracing is enabled, particularly in shader compilation decisions and render pass setups. It’s important to note that this variable is also read-only and render thread safe.
When working with CVarPathTracing, developers should follow the same best practices as with r.PathTracing, ensuring that they check for both ray tracing support and path tracing enablement before utilizing path tracing features in their code.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:6
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarPathTracing(
TEXT("r.PathTracing"),
1,
TEXT("Enables the path tracing renderer (to guard the compilation of path tracer specific material permutations)"),
ECVF_RenderThreadSafe | ECVF_ReadOnly
);
#if RHI_RAYTRACING
#Loc: <Workspace>/Engine/Plugins/Experimental/GPULightmass/Source/GPULightmassEditor/Private/GPULightmassEditorModule.cpp:155
Scope (from outer to inner):
file
function static bool IsPathTracingEnabled
Source code excerpt:
static bool IsPathTracingEnabled()
{
static const auto CVarPathTracing = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.PathTracing"));
return CVarPathTracing && CVarPathTracing->GetValueOnAnyThread() > 0;
}
void FGPULightmassEditorModule::StartupModule()
{
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>(TEXT("LevelEditor"));
#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineRenderPasses/Private/Graph/Nodes/MovieGraphPathTracerPassNode.cpp:63
Scope (from outer to inner):
file
function void UMovieGraphPathTracerRenderPassNode::SetupImpl
Source code excerpt:
if (IsRayTracingEnabled())
{
if (const IConsoleVariable* PathTracingCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.PathTracing")))
{
bSupportsPathTracing = PathTracingCVar->GetInt() != 0;
}
}
// Warn if the path tracer is being used, but it's not enabled in the Rendering settings. The path tracer won't work otherwise.
#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineRenderPasses/Private/MoviePipelineDeferredPasses.cpp:1055
Scope (from outer to inner):
file
function bool UMoviePipelineDeferredPassBase::CheckIfPathTracerIsSupported
Source code excerpt:
if (IsRayTracingEnabled())
{
IConsoleVariable* PathTracingCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.PathTracing"));
if (PathTracingCVar)
{
bSupportsPathTracing = PathTracingCVar->GetInt() != 0;
}
}
return bSupportsPathTracing;
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/SEditorViewportViewMenu.cpp:146
Scope (from outer to inner):
file
function void SEditorViewportViewMenu::FillViewMenu
Source code excerpt:
if (IsRayTracingEnabled())
{
static auto PathTracingCvar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.PathTracing"));
const bool bPathTracingSupported = FDataDrivenShaderPlatformInfo::GetSupportsPathTracing(GMaxRHIShaderPlatform);
const bool bPathTracingEnabled = PathTracingCvar && PathTracingCvar->GetValueOnAnyThread() != 0;
if (bPathTracingSupported && bPathTracingEnabled)
{
Section.AddMenuEntry(BaseViewportActions.PathTracingMode, UViewModeUtils::GetViewModeDisplayName(VMI_PathTracing));
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:465
Scope (from outer to inner):
file
function static bool ShouldCompilePathTracingDenoiserShadersForProject
Source code excerpt:
static bool ShouldCompilePathTracingDenoiserShadersForProject(EShaderPlatform ShaderPlatform)
{
static const auto CVarLocalVariablePathTracing = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.PathTracing"));
const int PathTracing = CVarLocalVariablePathTracing ? CVarLocalVariablePathTracing->GetValueOnAnyThread() : 0;
return ShouldCompileRayTracingShadersForProject(ShaderPlatform) &&
FDataDrivenShaderPlatformInfo::GetSupportsPathTracing(ShaderPlatform) &&
PathTracing != 0;
}
#Associated Variable and Callsites
This variable is associated with another variable named CVarPathTracing
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/GPULightmass/Source/GPULightmassEditor/Private/GPULightmassEditorModule.cpp:155
Scope (from outer to inner):
file
function static bool IsPathTracingEnabled
Source code excerpt:
static bool IsPathTracingEnabled()
{
static const auto CVarPathTracing = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.PathTracing"));
return CVarPathTracing && CVarPathTracing->GetValueOnAnyThread() > 0;
}
void FGPULightmassEditorModule::StartupModule()
{
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>(TEXT("LevelEditor"));
LevelEditorModule.OnTabManagerChanged().AddRaw(this, &FGPULightmassEditorModule::RegisterTabSpawner);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:5
Scope: file
Source code excerpt:
#include "PathTracingDenoiser.h"
TAutoConsoleVariable<int32> CVarPathTracing(
TEXT("r.PathTracing"),
1,
TEXT("Enables the path tracing renderer (to guard the compilation of path tracer specific material permutations)"),
ECVF_RenderThreadSafe | ECVF_ReadOnly
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:710
Scope (from outer to inner):
file
function static bool ShouldCompilePathTracingShadersForProject
Source code excerpt:
return ShouldCompileRayTracingShadersForProject(ShaderPlatform) &&
FDataDrivenShaderPlatformInfo::GetSupportsPathTracing(ShaderPlatform) &&
CVarPathTracing.GetValueOnAnyThread() != 0;
}
static bool ShouldCompileGPULightmassShadersForProject(EShaderPlatform ShaderPlatform)
{
#if WITH_EDITOR
if (!ShouldCompileRayTracingShadersForProject(ShaderPlatform))
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:2461
Scope: file
Source code excerpt:
}
if (CVarPathTracing.GetValueOnRenderThread() == 0)
{
// Path tracing is not enabled on this project (should not be seen by end-users since the menu entry to pick path tracing should be hidden)
// If they reach this code through ShowFlag manipulation, they may observe an incomplete image. Is there a way to inform the user here?
return;
}