r.HeterogeneousVolumes.OrthoGrid.VoxelizationMode

r.HeterogeneousVolumes.OrthoGrid.VoxelizationMode

#Overview

name: r.HeterogeneousVolumes.OrthoGrid.VoxelizationMode

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.OrthoGrid.VoxelizationMode is to control the voxelization mode for heterogeneous volumes in Unreal Engine’s rendering system. This setting variable is specifically related to the orthographic grid used in heterogeneous volume rendering.

This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the heterogeneous volumes subsystem. Based on the callsites, it’s clear that this variable is utilized in the HeterogeneousVolumesVoxelGridPipeline.cpp file, which is part of the rendering pipeline for heterogeneous volumes.

The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with a default value of 1. The variable can be changed at runtime through console commands or programmatically.

The variable interacts with the rendering logic in the CalcGlobalBoundsAndMinimumVoxelSize function, where it determines whether to convert to pixel space or not.

Developers must be aware that this variable has two modes: 0: Screen-space voxel size (legacy behavior) 1: World-space voxel size (default)

The best practice when using this variable is to understand the implications of each mode on the rendering of heterogeneous volumes. The world-space voxel size (mode 1) is set as the default, suggesting it’s the preferred method for most scenarios. However, the screen-space voxel size (mode 0) is kept for legacy support.

Regarding the associated variable CVarHeterogeneousVolumesOrthoGridVoxelizationMode:

The purpose of CVarHeterogeneousVolumesOrthoGridVoxelizationMode is to provide a programmatic interface to the r.HeterogeneousVolumes.OrthoGrid.VoxelizationMode setting. It’s an internal representation of the console variable in the C++ code.

This associated variable is used directly in the rendering code to check the current voxelization mode. It’s accessed using the GetValueOnAnyThread() method, which suggests it can be safely read from any thread.

The value of this variable is set when the console variable is initialized or changed.

Developers should be aware that changes to the console variable will be reflected in this associated variable. When using this variable in code, it’s best to always use the GetValueOnAnyThread() method to ensure you’re getting the most up-to-date value.

The best practice when using this variable is to treat it as read-only in most cases, allowing it to be controlled via the console variable system. If you need to change it programmatically, ensure you understand the implications on the rendering pipeline and use the appropriate methods to modify console variables.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesOrthoGridVoxelizationMode(
	TEXT("r.HeterogeneousVolumes.OrthoGrid.VoxelizationMode"),
	1,
	TEXT("Voxelization mode (Default = 1)\n")
	TEXT("0: Screen-space voxel size (legacy behavior)\n")
	TEXT("1: World-space voxel size\n"),
	ECVF_RenderThreadSafe
);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesOrthoGridVoxelizationMode(
	TEXT("r.HeterogeneousVolumes.OrthoGrid.VoxelizationMode"),
	1,
	TEXT("Voxelization mode (Default = 1)\n")
	TEXT("0: Screen-space voxel size (legacy behavior)\n")
	TEXT("1: World-space voxel size\n"),
	ECVF_RenderThreadSafe

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

Scope (from outer to inner):

file
function     void CalcGlobalBoundsAndMinimumVoxelSize

Source code excerpt:

)
{
	const bool bConvertToPixelSpace = (CVarHeterogeneousVolumesOrthoGridVoxelizationMode.GetValueOnAnyThread() == 0);
	TopLevelGridBounds = FBoxSphereBounds(ForceInit);
	GlobalMinimumVoxelSize = BuildOptions.MinimumVoxelSizeOutsideFrustum;

	// Cycle through all Volume PrimitiveSceneProxies to collect bounds information and minimum voxel-size
	for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
	{