landscape.DirtyHeightmapHeightThreshold

landscape.DirtyHeightmapHeightThreshold

#Overview

name: landscape.DirtyHeightmapHeightThreshold

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 landscape.DirtyHeightmapHeightThreshold is to set a threshold for detecting changes in landscape heightmap heights, specifically to avoid imprecision issues on certain GPUs. This setting variable is part of Unreal Engine 5’s landscape system, which is responsible for terrain rendering and manipulation.

The Unreal Engine subsystem that relies on this setting variable is the Landscape module, as evidenced by its usage in the LandscapeEditLayers.cpp file.

The value of this variable is set through a console variable (CVar) system, which allows for runtime configuration. It is initialized with a default value of 0 in the C++ code.

This variable interacts closely with another variable named CVarLandscapeDirtyHeightmapHeightThreshold, which is the associated console variable that shares the same value and purpose.

Developers must be aware that this threshold affects the sensitivity of height change detection in landscape editing. A value greater than 0 will only detect height changes that exceed the specified threshold, which can help mitigate GPU-specific imprecision issues.

Best practices when using this variable include:

  1. Setting it to 0 for maximum precision in height change detection.
  2. Adjusting the value if GPU-specific issues are encountered, starting with small values and increasing as needed.
  3. Testing the landscape editing behavior on target hardware to find the optimal threshold.

Regarding the associated variable CVarLandscapeDirtyHeightmapHeightThreshold:

The purpose of CVarLandscapeDirtyHeightmapHeightThreshold is to provide programmatic access to the landscape.DirtyHeightmapHeightThreshold setting within the C++ code.

This console variable is used in the Landscape module, specifically in the ALandscape class’s HasTextureDataChanged function.

The value of this variable is set through the console variable system and can be accessed at runtime using the GetValueOnGameThread() method.

It directly interacts with the landscape.DirtyHeightmapHeightThreshold setting, serving as the C++ interface for that configuration option.

Developers should be aware that changes to this console variable will directly affect the behavior of landscape height change detection in the engine.

Best practices for using this variable include:

  1. Using it in conjunction with CVarLandscapeDirtyHeightmapNormalThreshold for comprehensive landscape change detection.
  2. Considering performance implications when adjusting this value, as it may affect the frequency of texture updates.
  3. Documenting any non-zero values used in production to ensure consistency across different development environments.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:146

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarLandscapeDirtyHeightmapHeightThreshold(
	TEXT("landscape.DirtyHeightmapHeightThreshold"),
	0,
	TEXT("Threshold to avoid imprecision issues on certain GPUs when detecting when a heightmap height changes, i.e. only a height difference > than this threshold (N over 16-bits uint height) will be detected as a change."));

TAutoConsoleVariable<int32> CVarLandscapeDirtyHeightmapNormalThreshold(
	TEXT("landscape.DirtyHeightmapNormalThreshold"),
	0,

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:145

Scope: file

Source code excerpt:

	TEXT("When dumping diffs for heightmap (landscape.DumpHeightmapDiff) or weightmap (landscape.DumpWeightmapDiff), dumps additional details about the pixels being different"));

TAutoConsoleVariable<int32> CVarLandscapeDirtyHeightmapHeightThreshold(
	TEXT("landscape.DirtyHeightmapHeightThreshold"),
	0,
	TEXT("Threshold to avoid imprecision issues on certain GPUs when detecting when a heightmap height changes, i.e. only a height difference > than this threshold (N over 16-bits uint height) will be detected as a change."));

TAutoConsoleVariable<int32> CVarLandscapeDirtyHeightmapNormalThreshold(
	TEXT("landscape.DirtyHeightmapNormalThreshold"),

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:5544

Scope (from outer to inner):

file
function     bool ALandscape::HasTextureDataChanged

Source code excerpt:

		else 
		{
			int32 DirtyHeightmapHeightThreshold = CVarLandscapeDirtyHeightmapHeightThreshold.GetValueOnGameThread();
			int32 DirtyHeightmapNormalThreshold = CVarLandscapeDirtyHeightmapNormalThreshold.GetValueOnGameThread();
			if (DirtyHeightmapHeightThreshold > 0 || DirtyHeightmapNormalThreshold > 0)
			{
				TRACE_CPUPROFILER_EVENT_SCOPE(DeepCompareHeightmap);
				for (int32 Index = 0; Index < TextureSize; ++Index)
				{