r.HeterogeneousVolumes.SparseVoxel

r.HeterogeneousVolumes.SparseVoxel

#Overview

name: r.HeterogeneousVolumes.SparseVoxel

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.SparseVoxel is to enable or disable sparse-voxel rendering algorithms for heterogeneous volumes in Unreal Engine 5’s rendering system.

This setting variable is primarily used in the Renderer module, specifically within the HeterogeneousVolumes subsystem. It’s defined in the HeterogeneousVolumes.cpp file, which suggests it’s a part of the engine’s volumetric rendering capabilities.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0, meaning the sparse-voxel rendering algorithms are disabled by default.

The associated variable CVarHeterogeneousVolumesSparseVoxel directly interacts with r.HeterogeneousVolumes.SparseVoxel. It’s used to access the value of the console variable in the C++ code.

Developers must be aware that this variable is render thread safe (ECVF_RenderThreadSafe), which means it can be safely accessed from the render thread without causing race conditions.

Best practices when using this variable include:

  1. Only enable it when sparse-voxel rendering is needed, as it may have performance implications.
  2. Test thoroughly when enabled to ensure it doesn’t negatively impact visual quality or performance.
  3. Consider combining it with other heterogeneous volume settings for optimal results.

Regarding the associated variable CVarHeterogeneousVolumesSparseVoxel:

The purpose of CVarHeterogeneousVolumesSparseVoxel is to provide a programmatic interface to access the value of r.HeterogeneousVolumes.SparseVoxel within the C++ code.

This variable is used in the Renderer module, specifically in the HeterogeneousVolumes namespace. It’s accessed in the UseSparseVoxelPipeline() function to determine whether the sparse-voxel pipeline should be used.

The value of CVarHeterogeneousVolumesSparseVoxel is set automatically by the CVar system based on the r.HeterogeneousVolumes.SparseVoxel console variable.

It interacts directly with r.HeterogeneousVolumes.SparseVoxel, essentially serving as its C++ representation.

Developers should be aware that this variable should be accessed using the GetValueOnRenderThread() method to ensure thread-safe access in render code.

Best practices for using CVarHeterogeneousVolumesSparseVoxel include:

  1. Always access it using GetValueOnRenderThread() in render thread code.
  2. Avoid caching its value for long periods, as it can be changed at runtime through the console.
  3. Use it in conjunction with other relevant heterogeneous volume settings for a cohesive rendering approach.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesSparseVoxel(
	TEXT("r.HeterogeneousVolumes.SparseVoxel"),
	0,
	TEXT("Uses sparse-voxel rendering algorithms (Default = 0)"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesSparseVoxelGenerationMipBias(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesSparseVoxel(
	TEXT("r.HeterogeneousVolumes.SparseVoxel"),
	0,
	TEXT("Uses sparse-voxel rendering algorithms (Default = 0)"),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
namespace    HeterogeneousVolumes
function     bool UseSparseVoxelPipeline

Source code excerpt:

	bool UseSparseVoxelPipeline()
	{
		return CVarHeterogeneousVolumesSparseVoxel.GetValueOnRenderThread() != 0;
	}

	bool ShouldRefineSparseVoxels()
	{
		return CVarHeterogeneousVolumesSparseVoxelRefinement.GetValueOnRenderThread() != 0;
	}