landscape.DirtyWeightmapThreshold

landscape.DirtyWeightmapThreshold

#Overview

name: landscape.DirtyWeightmapThreshold

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.DirtyWeightmapThreshold is to set a threshold for detecting changes in landscape weightmaps, helping to avoid imprecision issues on certain GPUs.

This setting variable is primarily used in the Landscape system of Unreal Engine 5. It’s specifically part of the landscape editing functionality, as evidenced by its location in the LandscapeEditLayers.cpp file.

The value of this variable is set through a console variable (CVar) system. It’s defined using TAutoConsoleVariable, which allows it to be changed at runtime through console commands or configuration files.

The associated variable CVarLandscapeDirtyWeightmapThreshold directly interacts with landscape.DirtyWeightmapThreshold. They share the same value and purpose.

Developers must be aware that this variable is used to determine when a weightmap is considered “changed.” It sets a threshold for the difference in weightmap channel values that must be exceeded for the engine to register a change. This is crucial for performance optimization and avoiding unnecessary updates.

Best practices when using this variable include:

  1. Setting it to a non-zero value if experiencing imprecision issues on certain GPUs.
  2. Adjusting it carefully, as it affects the sensitivity of detecting landscape weightmap changes.
  3. Testing thoroughly after modifying this value to ensure landscape editing behaves as expected.

Regarding the associated variable CVarLandscapeDirtyWeightmapThreshold:

Its purpose is identical to landscape.DirtyWeightmapThreshold - it’s the C++ variable that directly controls the threshold value.

It’s used in the Landscape subsystem, specifically in the ALandscape class for determining if texture data has changed.

The value is set when the console variable is initialized and can be accessed at runtime using the GetValueOnGameThread() method.

Developers should be aware that this variable is used in performance-critical code sections, such as the HasTextureDataChanged function. Changes to this value can impact the performance and behavior of landscape editing operations.

Best practices include:

  1. Using GetValueOnGameThread() to access the current value, ensuring thread-safety.
  2. Considering the performance implications when modifying this value, as it affects how frequently landscape updates are triggered.
  3. Documenting any changes made to this variable, as it can significantly impact landscape editing behavior.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarLandscapeDirtyWeightmapThreshold(
	TEXT("landscape.DirtyWeightmapThreshold"),
	0,
	TEXT("Threshold to avoid imprecision issues on certain GPUs when detecting when a weightmap changes, i.e. only a difference > than this threshold (N over each 8-bits uint weightmap channel)."));

TAutoConsoleVariable<int32> CVarLandscapeShowDirty(
	TEXT("landscape.ShowDirty"),
	0,

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	TEXT("Threshold to avoid imprecision issues on certain GPUs when detecting when a heightmap normal changes, i.e. only a normal channel difference > than this threshold (N over each 8-bits uint B & A channels independently) will be detected as a change."));

TAutoConsoleVariable<int32> CVarLandscapeDirtyWeightmapThreshold(
	TEXT("landscape.DirtyWeightmapThreshold"),
	0,
	TEXT("Threshold to avoid imprecision issues on certain GPUs when detecting when a weightmap changes, i.e. only a difference > than this threshold (N over each 8-bits uint weightmap channel)."));

TAutoConsoleVariable<int32> CVarLandscapeShowDirty(
	TEXT("landscape.ShowDirty"),

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

Scope (from outer to inner):

file
function     bool ALandscape::HasTextureDataChanged

Source code excerpt:

		if (bInIsWeightmap)
		{
			if (int32 DirtyWeightmapThreshold = CVarLandscapeDirtyWeightmapThreshold.GetValueOnGameThread(); DirtyWeightmapThreshold > 0)
			{
				TRACE_CPUPROFILER_EVENT_SCOPE(DeepCompareWeightmap);
				for (int32 Index = 0; Index < TextureSize; ++Index)
				{
					const FColor& OldColor = InOldData[Index];
					const FColor& NewColor = InNewData[Index];