r.PathTracing.CameraMediumTracking

r.PathTracing.CameraMediumTracking

#Overview

name: r.PathTracing.CameraMediumTracking

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.PathTracing.CameraMediumTracking is to enable automatic camera medium tracking in the path tracing rendering system of Unreal Engine 5. This feature is designed to detect when a camera starts inside water or solid glass automatically.

This setting variable is primarily used in the rendering system, specifically in the path tracing module of Unreal Engine 5. Based on the callsites, it’s clear that this variable is utilized in the Renderer module, as evidenced by its location in the PathTracing.cpp file.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning it’s enabled by default. Users can change this value at runtime using console commands.

The associated variable CVarPathTracingCameraMediumTracking interacts directly with r.PathTracing.CameraMediumTracking. They share the same value and purpose. This associated variable is used to retrieve the current setting value in the code.

Developers should be aware that this variable affects the behavior of the path tracing renderer, particularly in scenes where the camera might be placed inside transparent media like water or glass. When enabled, it can potentially improve rendering accuracy in these scenarios.

Best practices for using this variable include:

  1. Leave it enabled (default value of 1) unless there’s a specific reason to disable it.
  2. If experiencing unexpected rendering results in scenes with water or glass, check if this setting is enabled.
  3. Be aware that enabling this feature might have a small performance impact, so in performance-critical scenarios, it might be worth testing with this feature disabled.

Regarding the associated variable CVarPathTracingCameraMediumTracking:

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:338

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarPathTracingCameraMediumTracking(
	TEXT("r.PathTracing.CameraMediumTracking"),
	1,
	TEXT("Enables automatic camera medium tracking to detect when a camera starts inside water or solid glass automatically (default = 1)\n")
	TEXT("0: off\n")
	TEXT("1: on (default)\n"),
	ECVF_RenderThreadSafe
);

#Associated Variable and Callsites

This variable is associated with another variable named CVarPathTracingCameraMediumTracking. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:337

Scope: file

Source code excerpt:

);

TAutoConsoleVariable<int32> CVarPathTracingCameraMediumTracking(
	TEXT("r.PathTracing.CameraMediumTracking"),
	1,
	TEXT("Enables automatic camera medium tracking to detect when a camera starts inside water or solid glass automatically (default = 1)\n")
	TEXT("0: off\n")
	TEXT("1: on (default)\n"),
	ECVF_RenderThreadSafe

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:2479

Scope: file

Source code excerpt:


	Config.LockedSamplingPattern = CVarPathTracingFrameIndependentTemporalSeed.GetValueOnRenderThread() == 0;
	Config.UseCameraMediumTracking = CVarPathTracingCameraMediumTracking.GetValueOnRenderThread() != 0;
	Config.UseAdaptiveSampling = bUseExperimental && CVarPathTracingAdaptiveSampling.GetValueOnAnyThread() != 0;
	Config.AdaptiveSamplingThreshold = CVarPathTracingAdaptiveSamplingErrorThreshold.GetValueOnRenderThread();

	// compute an integer code of what show flags and booleans related to lights are currently enabled so we can detect changes
	Config.LightShowFlags = 0;
	Config.LightShowFlags |= View.Family->EngineShowFlags.SkyLighting           ? 1 << 0 : 0;