r.HeterogeneousVolumes.Tessellation.MinimumVoxelSizeOutsideFrustum

r.HeterogeneousVolumes.Tessellation.MinimumVoxelSizeOutsideFrustum

#Overview

name: r.HeterogeneousVolumes.Tessellation.MinimumVoxelSizeOutsideFrustum

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.Tessellation.MinimumVoxelSizeOutsideFrustum is to set the minimum voxel size for heterogeneous volumes outside the view frustum in the rendering system. This setting is part of Unreal Engine 5’s heterogeneous volumes rendering pipeline.

This setting variable is primarily used in the Renderer module, specifically in the HeterogeneousVolumes subsystem. It’s defined and used within the HeterogeneousVolumesVoxelGridPipeline.cpp file.

The value of this variable is set as a console variable with a default value of 100.0. It can be modified at runtime through the console or configuration files.

The associated variable CVarHeterogeneousVolumesMinimumVoxelSizeOutsideFrustum directly interacts with this setting. It’s used to retrieve the value in the GetMinimumVoxelSizeOutsideFrustum() function, where it’s also clamped to a minimum of 0.01.

Developers should be aware that this variable affects the performance and quality trade-off in rendering heterogeneous volumes. A larger minimum voxel size outside the frustum can improve performance but may reduce detail in areas outside the player’s view.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of your project and target hardware.
  2. Testing different values to find the optimal balance between performance and visual quality.
  3. Considering the impact on memory usage, as larger voxels require less memory.

Regarding the associated variable CVarHeterogeneousVolumesMinimumVoxelSizeOutsideFrustum:

The purpose of this variable is to provide a programmatic way to access and modify the r.HeterogeneousVolumes.Tessellation.MinimumVoxelSizeOutsideFrustum setting within the C++ code.

It’s used in the Renderer module, specifically in the HeterogeneousVolumes subsystem, to retrieve the current value of the minimum voxel size setting.

The value of this variable is set when the console variable is created, and it’s updated whenever the console variable is changed.

This variable directly interacts with the r.HeterogeneousVolumes.Tessellation.MinimumVoxelSizeOutsideFrustum setting, serving as its in-code representation.

Developers should be aware that this variable is render thread safe (ECVF_RenderThreadSafe), meaning it can be safely accessed from the render thread.

Best practices when using this variable include:

  1. Using GetValueOnRenderThread() to retrieve its value, as shown in the GetMinimumVoxelSizeOutsideFrustum() function.
  2. Considering thread safety when accessing or modifying this variable in multi-threaded contexts.
  3. Using this variable instead of directly accessing the console variable string in performance-critical code paths.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarHeterogeneousVolumesMinimumVoxelSizeOutsideFrustum(
	TEXT("r.HeterogeneousVolumes.Tessellation.MinimumVoxelSizeOutsideFrustum"),
	100.0,
	TEXT("The minimum voxel size (Default = 100.0)"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesBottomLevelGridVoxelHashingMemoryInMegabytes(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<float> CVarHeterogeneousVolumesMinimumVoxelSizeOutsideFrustum(
	TEXT("r.HeterogeneousVolumes.Tessellation.MinimumVoxelSizeOutsideFrustum"),
	100.0,
	TEXT("The minimum voxel size (Default = 100.0)"),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
namespace    HeterogeneousVolumes
function     float GetMinimumVoxelSizeOutsideFrustum

Source code excerpt:

	float GetMinimumVoxelSizeOutsideFrustum()
	{
		return FMath::Max(CVarHeterogeneousVolumesMinimumVoxelSizeOutsideFrustum.GetValueOnRenderThread(), 0.01);
	}

	int32 GetMarchingMode()
	{
		return FMath::Clamp(CVarHeterogeneousVolumesMarchingMode.GetValueOnRenderThread(), 0, 3);
	}