r.HeterogeneousVolumes.Velocity

r.HeterogeneousVolumes.Velocity

#Overview

name: r.HeterogeneousVolumes.Velocity

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.Velocity is to control whether Heterogeneous Volumes velocity is written to the feature buffer in Unreal Engine’s rendering system. This setting is part of the Heterogeneous Volumes rendering feature, which is likely used for advanced volumetric effects or fluid simulations.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the Heterogeneous Volumes component. This can be inferred from the file location (Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumes.cpp) where the variable is defined and used.

The value of this variable is set as a console variable, which means it can be changed at runtime through the console or configuration files. By default, it is set to 0, indicating that velocity writing is disabled by default.

The associated variable CVarHeterogeneousVolumesVelocity interacts directly with r.HeterogeneousVolumes.Velocity. It is an instance of TAutoConsoleVariable that wraps the console variable and provides a programmatic way to access its value.

Developers must be aware that:

  1. This variable is render thread safe (ECVF_RenderThreadSafe), meaning it can be safely accessed from the render thread.
  2. The setting is binary (0 or non-0), where 0 disables velocity writing and any non-zero value enables it.
  3. Enabling this feature may have performance implications, as it involves additional writing to the feature buffer.

Best practices when using this variable include:

  1. Only enable it when necessary, as it may impact performance.
  2. Use it in conjunction with other Heterogeneous Volumes settings for optimal results.
  3. Test thoroughly with different values to understand its impact on your specific use case.

Regarding the associated variable CVarHeterogeneousVolumesVelocity:

The purpose of CVarHeterogeneousVolumesVelocity is to provide a programmatic interface to the r.HeterogeneousVolumes.Velocity console variable within the C++ code.

This variable is used within the Renderer module, specifically in the HeterogeneousVolumes namespace. It’s used to query the current state of the velocity writing feature.

The value of CVarHeterogeneousVolumesVelocity is set when the console variable r.HeterogeneousVolumes.Velocity is modified, either through the console or configuration files.

CVarHeterogeneousVolumesVelocity interacts directly with r.HeterogeneousVolumes.Velocity, essentially serving as its C++ representation.

Developers should be aware that:

  1. This variable should be accessed using GetValueOnRenderThread() when used in render thread contexts.
  2. It returns an int32 value, which is interpreted as a boolean (0 for false, non-0 for true).

Best practices for using CVarHeterogeneousVolumesVelocity include:

  1. Use it to check the current state of velocity writing in rendering code.
  2. Avoid frequent checks in performance-critical sections, as console variable access may have some overhead.
  3. Consider caching the value if it’s used frequently and doesn’t need to reflect real-time changes.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesVelocity(
	TEXT("r.HeterogeneousVolumes.Velocity"),
	0,
	TEXT("Writes Heterogeneous Volumes velocity to the feature buffer (Default = 0)"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesCLOD(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesVelocity(
	TEXT("r.HeterogeneousVolumes.Velocity"),
	0,
	TEXT("Writes Heterogeneous Volumes velocity to the feature buffer (Default = 0)"),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
namespace    HeterogeneousVolumes
function     bool ShouldWriteVelocity

Source code excerpt:

	bool ShouldWriteVelocity()
	{
		return CVarHeterogeneousVolumesVelocity.GetValueOnRenderThread() != 0;
	}

	bool UseContinuousLOD()
	{
		return CVarHeterogeneousVolumesCLOD.GetValueOnRenderThread() != 0;
	}