r.HeterogeneousVolumes.FrustumGrid

r.HeterogeneousVolumes.FrustumGrid

#Overview

name: r.HeterogeneousVolumes.FrustumGrid

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.FrustumGrid is to enable or disable the frustum voxel grid in the heterogeneous volumes rendering system. This setting variable is part of Unreal Engine’s rendering system, specifically for handling volumetric effects.

Based on the callsites, this setting variable is primarily used in the Renderer module, particularly in the HeterogeneousVolumes subsystem. The code is located in the HeterogeneousVolumesVoxelGridPipeline.cpp file, which suggests it’s part of the pipeline for rendering heterogeneous volumes using a voxel grid approach.

The value of this variable is set as a console variable using TAutoConsoleVariable. It’s initialized with a default value of 1, meaning the frustum voxel grid is enabled by default.

This variable interacts with an associated variable named CVarHeterogeneousVolumesEnableFrustumVoxelGrid. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable is render thread safe (ECVF_RenderThreadSafe), meaning it can be safely accessed from the render thread. Changes to this variable will affect the rendering of heterogeneous volumes, potentially impacting performance and visual quality.

Best practices when using this variable include:

  1. Only disable it if you’re experiencing performance issues related to heterogeneous volumes rendering.
  2. Test thoroughly after changing its value, as it may significantly impact the visual quality of volumetric effects.
  3. Consider the impact on different hardware configurations, as the performance impact may vary.

Regarding the associated variable CVarHeterogeneousVolumesEnableFrustumVoxelGrid:

The purpose of CVarHeterogeneousVolumesEnableFrustumVoxelGrid is the same as r.HeterogeneousVolumes.FrustumGrid, which is to enable or disable the frustum voxel grid in the heterogeneous volumes rendering system.

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

The value of this variable is set using TAutoConsoleVariable, with a default value of 1 (enabled).

It interacts directly with the r.HeterogeneousVolumes.FrustumGrid console variable, sharing the same value.

Developers should be aware that this variable is accessed using GetValueOnRenderThread(), indicating it’s designed for use in render thread contexts.

Best practices for using this variable include:

  1. Use it consistently with r.HeterogeneousVolumes.FrustumGrid, as they represent the same setting.
  2. When querying the value, use the EnableFrustumVoxelGrid() function provided in the HeterogeneousVolumes namespace, which handles the conversion from int32 to bool.
  3. Be cautious when modifying this value at runtime, as it may affect ongoing rendering processes.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesEnableFrustumVoxelGrid(
	TEXT("r.HeterogeneousVolumes.FrustumGrid"),
	1,
	TEXT("Enables a frustum voxel grid (Default = 1)"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<float> CVarHeterogeneousVolumesFrustumGridShadingRate(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

#include "VolumetricFog.h"

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesEnableFrustumVoxelGrid(
	TEXT("r.HeterogeneousVolumes.FrustumGrid"),
	1,
	TEXT("Enables a frustum voxel grid (Default = 1)"),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
namespace    HeterogeneousVolumes
function     bool EnableFrustumVoxelGrid

Source code excerpt:

	bool EnableFrustumVoxelGrid()
	{
		return CVarHeterogeneousVolumesEnableFrustumVoxelGrid.GetValueOnRenderThread() != 0;
	}

	float GetShadingRateForFrustumGrid()
	{
		return FMath::Max(CVarHeterogeneousVolumesFrustumGridShadingRate.GetValueOnRenderThread(), 0.1);
	}