r.PathTracing.MaxRaymarchSteps

r.PathTracing.MaxRaymarchSteps

#Overview

name: r.PathTracing.MaxRaymarchSteps

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.MaxRaymarchSteps is to set an upper limit on the number of ray marching steps in volumes during path tracing in Unreal Engine’s rendering system.

This setting variable is primarily used by the path tracing subsystem within Unreal Engine’s rendering module. It specifically affects the volume rendering aspect of path tracing.

The value of this variable is set through the console variable system in Unreal Engine. It’s defined with a default value of 256, but can be adjusted at runtime.

The associated variable CVarPathTracingMaxRaymarchSteps directly interacts with r.PathTracing.MaxRaymarchSteps. It’s the C++ representation of the console variable and is used to retrieve the current value of the setting.

Developers must be aware that this variable affects the quality and performance trade-off in volume rendering during path tracing. Increasing the value can reduce bias in the rendering results but may also increase computational cost.

Best practices when using this variable include:

  1. Keeping the default value (256) unless specific issues are observed.
  2. Increasing the value if bias artifacts are noticed in volume rendering, especially in complex scenes.
  3. Monitoring performance impact when adjusting this value, as higher values may increase render times.
  4. Using it in conjunction with other path tracing settings for optimal results.

Regarding the associated variable CVarPathTracingMaxRaymarchSteps:

The purpose of CVarPathTracingMaxRaymarchSteps is to provide programmatic access to the r.PathTracing.MaxRaymarchSteps setting within the C++ code of the rendering system.

This variable is used within the rendering module, specifically in the path tracing implementation. It’s accessed in the PreparePathTracingData function to set up the path tracing data structure.

The value of CVarPathTracingMaxRaymarchSteps is set when the r.PathTracing.MaxRaymarchSteps console variable is modified. It reflects the current state of the setting.

CVarPathTracingMaxRaymarchSteps interacts directly with the r.PathTracing.MaxRaymarchSteps console variable, serving as its C++ representation.

Developers should be aware that this variable is used to retrieve the current value of the setting on the render thread, ensuring thread-safe access to the configuration.

Best practices for using CVarPathTracingMaxRaymarchSteps include:

  1. Always accessing it using the GetValueOnRenderThread() method to ensure thread-safety.
  2. Not modifying this variable directly, but instead changing the r.PathTracing.MaxRaymarchSteps console variable.
  3. Using it in render thread operations only, as indicated by its ECVF_RenderThreadSafe flag.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarPathTracingMaxRaymarchSteps(
	TEXT("r.PathTracing.MaxRaymarchSteps"),
	256,
	TEXT("Upper limit on the number of ray marching steps in volumes. This limit should not be hit in most cases, but raising it can reduce bias in case it is. (default = 256)."),
	ECVF_RenderThreadSafe
);

TAutoConsoleVariable<int32> CVarPathTracingMISCompensation(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

TAutoConsoleVariable<int32> CVarPathTracingMaxRaymarchSteps(
	TEXT("r.PathTracing.MaxRaymarchSteps"),
	256,
	TEXT("Upper limit on the number of ray marching steps in volumes. This limit should not be hit in most cases, but raising it can reduce bias in case it is. (default = 256)."),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
function     static void PreparePathTracingData

Source code excerpt:

	PathTracingData.MeshDecalBias = CVarPathTracingMeshDecalBias.GetValueOnRenderThread();

	PathTracingData.MaxRaymarchSteps = CVarPathTracingMaxRaymarchSteps.GetValueOnRenderThread();

	// NOTE: Diffuse and Specular show flags also modify the override colors, but we prefer to tie those to the lighting contribution mechanism below which is more principled
	PathTracingData.ApplyDiffuseSpecularOverrides =
		ShowFlags.LightingOnlyOverride       != 0 ||
		ShowFlags.OverrideDiffuseAndSpecular != 0 ||
		ShowFlags.ReflectionOverride         != 0;