r.HeterogeneousVolumes.DepthSort

r.HeterogeneousVolumes.DepthSort

#Overview

name: r.HeterogeneousVolumes.DepthSort

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.HeterogeneousVolumes.DepthSort is to control the depth sorting of heterogeneous volumes in the rendering pipeline. This setting variable is used in the rendering system, specifically for managing the rendering order of heterogeneous volumes.

This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the HeterogeneousVolumes subsystem. Based on the callsites, it’s referenced in the file HeterogeneousVolumes.cpp, which is part of the rendering pipeline.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning depth sorting is enabled by default.

The associated variable CVarHeterogeneousVolumesDepthSort directly interacts with r.HeterogeneousVolumes.DepthSort. They share the same value and purpose.

Developers must be aware that this variable affects the rendering order of heterogeneous volumes. When enabled (set to 1), it causes the renderer to iterate over volumes in a depth-sorted order based on their centroids. This can impact the visual output and potentially the performance of the rendering pipeline.

Best practices when using this variable include:

  1. Consider the performance implications of enabling depth sorting, especially in scenes with many heterogeneous volumes.
  2. Test the visual impact of enabling and disabling this feature to ensure it provides the desired visual results for your specific use case.
  3. Be mindful of how this setting interacts with other rendering features and settings related to heterogeneous volumes.

Regarding the associated variable CVarHeterogeneousVolumesDepthSort:

The purpose of CVarHeterogeneousVolumesDepthSort is the same as r.HeterogeneousVolumes.DepthSort - to control the depth sorting of heterogeneous volumes in the rendering pipeline.

It is used in the Renderer module, specifically in the HeterogeneousVolumes subsystem.

The value is set through the console variable system, with a default value of 1.

It directly interacts with r.HeterogeneousVolumes.DepthSort, sharing the same value and purpose.

Developers should be aware that this is the actual variable used in the C++ code to control the behavior, while r.HeterogeneousVolumes.DepthSort is the console command used to modify it.

Best practices include using this variable for runtime checks in the rendering code, as seen in the provided code excerpt where it’s used in a conditional statement to determine whether to perform depth sorting.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumes.cpp:209

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesDepthSort(
	TEXT("r.HeterogeneousVolumes.DepthSort"),
	1,
	TEXT("Iterates over volumes in depth-sorted order, based on its centroid (Default = 1)"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesApplyHeightFog(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumes.cpp:208

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesDepthSort(
	TEXT("r.HeterogeneousVolumes.DepthSort"),
	1,
	TEXT("Iterates over volumes in depth-sorted order, based on its centroid (Default = 1)"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumes.cpp:827

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderHeterogeneousVolumes

Source code excerpt:


				// Provide coarse depth-sorting, based on camera-distance to world centroid
				bool bDepthSort = CVarHeterogeneousVolumesDepthSort.GetValueOnRenderThread() == 1;
				if (bDepthSort)
				{
					struct FDepthCompareHeterogeneousVolumes
					{
						FVector WorldCameraOrigin;
						FDepthCompareHeterogeneousVolumes(FViewInfo& View) : WorldCameraOrigin(View.ViewMatrices.GetViewOrigin()) {}