r.HeterogeneousVolumes.Tessellation.MajorantGrid

r.HeterogeneousVolumes.Tessellation.MajorantGrid

#Overview

name: r.HeterogeneousVolumes.Tessellation.MajorantGrid

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.MajorantGrid is to enable or disable the building of majorant grids for accelerating volume tracking in heterogeneous volumes rendering. This setting is specifically related to the rendering system, particularly the heterogeneous volumes subsystem.

This setting variable is used in the Renderer module of Unreal Engine 5, specifically within the HeterogeneousVolumes namespace. It’s part of the voxel grid pipeline for heterogeneous volumes rendering.

The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 1, meaning the majorant grid feature is enabled by default.

The associated variable CVarHeterogeneousVolumesEnableMajorantGrid directly interacts with this setting. It’s defined as a TAutoConsoleVariable, which allows for runtime modification of the setting.

Developers must be aware that this setting is render thread safe (ECVF_RenderThreadSafe), meaning it can be changed safely during runtime without causing threading issues. However, changes to this setting will affect rendering performance and potentially visual quality, so it should be used judiciously.

Best practices when using this variable include:

  1. Only disable it if you’re experiencing performance issues related to heterogeneous volumes rendering and have confirmed that the majorant grid is the bottleneck.
  2. Profile your application with and without this feature enabled to understand its impact on your specific use case.
  3. Consider exposing this setting in your game’s advanced graphics options for users with varying hardware capabilities.

Regarding the associated variable CVarHeterogeneousVolumesEnableMajorantGrid:

The purpose of CVarHeterogeneousVolumesEnableMajorantGrid is to provide a programmatic way to access and modify the r.HeterogeneousVolumes.Tessellation.MajorantGrid setting.

This variable is used in the same Renderer module and HeterogeneousVolumes namespace. It’s primarily used to check the current state of the majorant grid feature in the EnableMajorantGrid() function.

The value of this variable is set through the CVar system and can be modified at runtime.

Developers should be aware that this variable is accessed on the render thread (GetValueOnRenderThread()), which is important for thread safety considerations.

Best practices for using this variable include:

  1. Use the provided EnableMajorantGrid() function to check the state of this feature rather than directly accessing the CVar.
  2. If you need to modify this setting programmatically, ensure you’re doing so in a thread-safe manner, respecting the render thread.
  3. Consider caching the value if you’re checking it frequently, as accessing CVars can have a small performance cost.

#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:184

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesEnableMajorantGrid(
	TEXT("r.HeterogeneousVolumes.Tessellation.MajorantGrid"),
	1,
	TEXT("Enables building majorant grids to accelerate volume tracking (Default = 0)\n"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesEnableMajorantGridMax(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesEnableMajorantGrid(
	TEXT("r.HeterogeneousVolumes.Tessellation.MajorantGrid"),
	1,
	TEXT("Enables building majorant grids to accelerate volume tracking (Default = 0)\n"),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
namespace    HeterogeneousVolumes
function     bool EnableMajorantGrid

Source code excerpt:

	bool EnableMajorantGrid()
	{
		return CVarHeterogeneousVolumesEnableMajorantGrid.GetValueOnRenderThread() != 0;
	}

	float CalcTanHalfFOV(float FOVInDegrees)
	{
		return FMath::Tan(FMath::DegreesToRadians(FOVInDegrees * 0.5));
	}