r.PathTracing.AdaptiveSampling.Visualize

r.PathTracing.AdaptiveSampling.Visualize

#Overview

name: r.PathTracing.AdaptiveSampling.Visualize

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.AdaptiveSampling.Visualize is to provide visualization options for adaptive sampling in the path tracing system of Unreal Engine 5. It allows developers to visually understand how adaptive sampling is working in their scenes.

This setting variable is primarily used in the rendering system, specifically within the path tracing subsystem of Unreal Engine 5. Based on the callsites, it’s evident that this variable is utilized in the Renderer module, particularly in the PathTracing.cpp file.

The value of this variable is set through a console variable (CVarPathTracingAdaptiveSamplingVisualize) with a default value of 0. It can be changed at runtime through console commands or programmatically.

The variable interacts with other path tracing and rendering-related variables, such as those controlling adaptive sampling thresholds and progress display.

Developers must be aware that this variable offers different visualization modes: 0: Off (default) 1: Visualize active pixels with a heatmap (converged pixels are displayed as is) 2: Visualize sample count heatmap (against current max samples) 3-7: Visualize variance mip levels

Best practices when using this variable include:

  1. Use it during development and debugging to understand how adaptive sampling is performing in different parts of the scene.
  2. Combine it with other path tracing settings to optimize rendering quality and performance.
  3. Remember to disable it (set to 0) for final builds or when visualization is not needed.

Regarding the associated variable CVarPathTracingAdaptiveSamplingVisualize: This is the actual console variable that controls the r.PathTracing.AdaptiveSampling.Visualize setting. It’s defined using TAutoConsoleVariable, which means it’s an integer value that can be changed at runtime. The variable is used in the rendering pipeline to determine which visualization mode should be applied when rendering the path-traced scene. Developers can access and modify this variable programmatically or through console commands to change the visualization mode during runtime or debugging sessions.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarPathTracingAdaptiveSamplingVisualize(
	TEXT("r.PathTracing.AdaptiveSampling.Visualize"),
	0,
	TEXT("Select a visualization mode to help understand how adaptive sampling is working.\n")
	TEXT("0: off\n")
	TEXT("1: Visualize active pixels with heatmap (converged pixels are displayed as is)\n")
	TEXT("2: Visualize sample count heatmap (against current max samples)\n")
	TEXT("3-7: Visualize variance mip levels\n"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

TAutoConsoleVariable<int32> CVarPathTracingAdaptiveSamplingVisualize(
	TEXT("r.PathTracing.AdaptiveSampling.Visualize"),
	0,
	TEXT("Select a visualization mode to help understand how adaptive sampling is working.\n")
	TEXT("0: off\n")
	TEXT("1: Visualize active pixels with heatmap (converged pixels are displayed as is)\n")
	TEXT("2: Visualize sample count heatmap (against current max samples)\n")

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

Scope: file

Source code excerpt:

	DisplayParameters->ProgressDisplayEnabled = CVarPathTracingProgressDisplay.GetValueOnRenderThread();
	DisplayParameters->AdaptiveSamplingErrorThreshold = Config.AdaptiveSamplingThreshold;
	DisplayParameters->AdaptiveSamplingVisualize = CVarPathTracingAdaptiveSamplingVisualize.GetValueOnRenderThread();
	DisplayParameters->VarianceTextureDims = FIntVector(DispatchResX, DispatchResY, NumVarianceMips);
	DisplayParameters->ViewUniformBuffer = View.ViewUniformBuffer;
	DisplayParameters->RadianceTexture = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(DenoisedRadianceTexture ? DenoisedRadianceTexture : RadianceTexture));
	DisplayParameters->VarianceTexture = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(VarianceTexture ? VarianceTexture : GSystemTextures.GetBlackDummy(GraphBuilder)));
	DisplayParameters->NormalDepthTexture = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(NormalTexture));
	DisplayParameters->RenderTargets[0] = FRenderTargetBinding(SceneColorOutputTexture, ERenderTargetLoadAction::ELoad);