landscape.RemoveEmptyPaintLayersOnEdit
landscape.RemoveEmptyPaintLayersOnEdit
#Overview
name: landscape.RemoveEmptyPaintLayersOnEdit
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
This will analyze weightmaps on readback and remove unneeded allocations (for unpainted layers).
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of landscape.RemoveEmptyPaintLayersOnEdit is to analyze weightmaps on readback and remove unneeded allocations for unpainted layers in the Unreal Engine 5 landscape system.
This setting variable is primarily used in the Landscape module of Unreal Engine 5. It’s specifically related to the landscape editing and paint layer management system.
The value of this variable is set through a console variable (CVar) named CVarLandscapeRemoveEmptyPaintLayersOnEdit. It’s defined in the LandscapeEditLayers.cpp file and is currently set to 0 (disabled) by default.
The associated variable CVarLandscapeRemoveEmptyPaintLayersOnEdit directly interacts with landscape.RemoveEmptyPaintLayersOnEdit. They share the same value and purpose.
Developers must be aware that this feature is currently disabled (set to 0) due to a potential issue. As noted in the code comments, enabling this feature can lead to a permanent dirty-on-load state for landscapes. This occurs because the edit layers might allocate new weightmaps for missing layers (e.g., if a Blueprint brush writes to it), only to remove them after readback, marking the actor as dirty.
The best practice when using this variable would be to leave it disabled (0) unless specifically needed and fully understood. If enabled, developers should be prepared to handle potential issues with landscape dirty states and weightmap allocations.
Regarding the associated variable CVarLandscapeRemoveEmptyPaintLayersOnEdit:
Its purpose is the same as landscape.RemoveEmptyPaintLayersOnEdit - to control the behavior of removing empty paint layers during landscape editing.
It’s used in the Landscape module, specifically in the landscape editing and layer management system.
The value is set when the CVar is initialized in the LandscapeEditLayers.cpp file.
It directly interacts with the landscape.RemoveEmptyPaintLayersOnEdit console variable.
Developers should be aware that this variable is used to check whether the empty channel removal feature is enabled in the ResolveLayersTexture function of the ALandscape class.
Best practices for using this variable include careful consideration before enabling it, thorough testing of landscape editing workflows if enabled, and being prepared to handle potential issues with landscape dirty states and weightmap allocations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:181
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarLandscapeRemoveEmptyPaintLayersOnEdit(
TEXT("landscape.RemoveEmptyPaintLayersOnEdit"),
// TODO [jonathan.bard] : this has been disabled for now, since it can lead to a permanent dirty-on-load state for landscape, where the edit layers will do a new weightmap allocation for the missing layer
// (e.g. if a BP brush writes to it), only to remove it after readback, which will lead to the actor to be marked dirty. We need to separate the final from the source weightmap data to avoid this issue :
0,
TEXT("This will analyze weightmaps on readback and remove unneeded allocations (for unpainted layers)."));
void OnLandscapeEditLayersLocalMergeChanged(IConsoleVariable* CVar)
#Associated Variable and Callsites
This variable is associated with another variable named CVarLandscapeRemoveEmptyPaintLayersOnEdit
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:180
Scope: file
Source code excerpt:
TEXT("This will validate that weightmap usages in landscape proxies and their components don't get desynchronized with the landscape component layer allocations."));
TAutoConsoleVariable<int32> CVarLandscapeRemoveEmptyPaintLayersOnEdit(
TEXT("landscape.RemoveEmptyPaintLayersOnEdit"),
// TODO [jonathan.bard] : this has been disabled for now, since it can lead to a permanent dirty-on-load state for landscape, where the edit layers will do a new weightmap allocation for the missing layer
// (e.g. if a BP brush writes to it), only to remove it after readback, which will lead to the actor to be marked dirty. We need to separate the final from the source weightmap data to avoid this issue :
0,
TEXT("This will analyze weightmaps on readback and remove unneeded allocations (for unpainted layers)."));
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:5696
Scope (from outer to inner):
file
function bool ALandscape::ResolveLayersTexture
Source code excerpt:
static constexpr uint32 AllChannelsAllZerosMask = 15;
uint32 AllZerosTextureChannelMask = AllChannelsAllZerosMask;
const bool bCheckForEmptyChannels = CVarLandscapeRemoveEmptyPaintLayersOnEdit.GetValueOnGameThread() != 0;
if (bIsWeightmap && bCheckForEmptyChannels)
{
TRACE_CPUPROFILER_EVENT_SCOPE(LandscapeLayers_AnalyzeWeightmap);
const FColor* TextureData = reinterpret_cast<const FColor*>(InOutputTexture->Source.LockMipReadOnly(0));
const int32 TexSize = OutMipsData[0].Num();
// We can stop iterating as soon as all of the channels are non-zero :