AlphaTextureChannel
AlphaTextureChannel
#Overview
name: AlphaTextureChannel
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 11
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of AlphaTextureChannel is to specify which color channel of an alpha texture should be used in landscape editing operations within Unreal Engine 5. This setting is primarily used in the landscape editing system, particularly for brush operations.
AlphaTextureChannel is utilized by the Landscape Editor module, specifically in the brush system for landscape editing. It’s referenced in the LandscapeEdModeBrushes and LandscapeEditorObject classes, which are part of the landscape editing tools.
The value of this variable is set in several ways:
- It’s initialized in the ULandscapeEditorObject constructor.
- It can be modified through the editor UI, as evidenced by the property customization in LandscapeEditorDetailCustomization_AlphaBrush.
- It’s loaded from and saved to the editor’s project-specific ini file.
This variable interacts closely with the AlphaTexture property, which represents the actual texture used for alpha operations. Together, they define how alpha values are extracted from a texture for brush operations.
Developers should be aware that:
- The channel selection affects how brush alpha values are calculated, impacting the appearance and behavior of landscape edits.
- Changes to this variable are immediately reflected in brush operations.
- The setting is persisted between editor sessions.
Best practices when using this variable include:
- Ensuring the selected channel contains the desired alpha information in the texture.
- Coordinating the channel selection with the design of alpha textures used in landscape editing.
- Being consistent in channel usage across a project to maintain predictable editing behavior.
- Considering performance implications when switching channels, as it may require texture data reprocessing.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:735, section: [LandscapeEdit]
- INI Section:
LandscapeEdit
- Raw value:
0
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEdModeBrushes.cpp:1316
Scope (from outer to inner):
file
class class FLandscapeBrushAlphaPattern : public FLandscapeBrushAlphaBase
function virtual void Tick
Source code excerpt:
FLinearColor AlphaTextureMask(
EdMode->UISettings->AlphaTextureChannel == ELandscapeTextureColorChannel::Red ? 1.0f : 0.0f,
EdMode->UISettings->AlphaTextureChannel == ELandscapeTextureColorChannel::Green ? 1.0f : 0.0f,
EdMode->UISettings->AlphaTextureChannel == ELandscapeTextureColorChannel::Blue ? 1.0f : 0.0f,
EdMode->UISettings->AlphaTextureChannel == ELandscapeTextureColorChannel::Alpha ? 1.0f : 0.0f);
for (const auto& BrushMaterialInstancePair : BrushMaterialInstanceMap)
{
UMaterialInstanceDynamic* const MaterialInstance = BrushMaterialInstancePair.Value.Get();
if (!MaterialInstance)
{
#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEdModeBrushes.cpp:1559
Scope (from outer to inner):
file
class class FLandscapeBrushAlpha : public FLandscapeBrushAlphaBase
function virtual void Tick
Source code excerpt:
);
FLinearColor AlphaTextureMask(EdMode->UISettings->AlphaTextureChannel == ELandscapeTextureColorChannel::Red ? 1.0f : 0.0f,
EdMode->UISettings->AlphaTextureChannel == ELandscapeTextureColorChannel::Green ? 1.0f : 0.0f,
EdMode->UISettings->AlphaTextureChannel == ELandscapeTextureColorChannel::Blue ? 1.0f : 0.0f,
EdMode->UISettings->AlphaTextureChannel == ELandscapeTextureColorChannel::Alpha ? 1.0f : 0.0f);
for (const auto& BrushMaterialInstancePair : BrushMaterialInstanceMap)
{
UMaterialInstanceDynamic* const MaterialInstance = BrushMaterialInstancePair.Value.Get();
#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorDetailCustomization_AlphaBrush.cpp:196
Scope (from outer to inner):
file
function BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION void FLandscapeEditorDetailCustomization_AlphaBrush::CustomizeDetails
Source code excerpt:
TSharedRef<IPropertyHandle> PropertyHandle_AlphaTexture = DetailBuilder.GetProperty(GET_MEMBER_NAME_CHECKED(ULandscapeEditorObject, AlphaTexture));
DetailBuilder.HideProperty(PropertyHandle_AlphaTexture);
TSharedRef<IPropertyHandle> PropertyHandle_AlphaTextureChannel = DetailBuilder.GetProperty(GET_MEMBER_NAME_CHECKED(ULandscapeEditorObject, AlphaTextureChannel));
DetailBuilder.HideProperty(PropertyHandle_AlphaTextureChannel);
BrushSettingsCategory.AddProperty(PropertyHandle_AlphaTexture)
.CustomWidget()
.NameContent()
[
#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorObject.cpp:115
Scope (from outer to inner):
file
function ULandscapeEditorObject::ULandscapeEditorObject
Source code excerpt:
, WorldSpacePatternBrushSettings(FVector2D::ZeroVector, 0.0f, false, 3200)
, AlphaTexture(nullptr)
, AlphaTextureChannel(ELandscapeTextureColorChannel::Red)
, AlphaTextureSizeX(1)
, AlphaTextureSizeY(1)
, BrushComponentSize(1)
, TargetDisplayOrder(ELandscapeLayerDisplayMode::Default)
, ShowUnusedLayers(true)
#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorObject.cpp:136
Scope (from outer to inner):
file
function ULandscapeEditorObject::ULandscapeEditorObject
Source code excerpt:
static FConstructorStatics ConstructorStatics;
SetAlphaTexture(ConstructorStatics.AlphaTexture.Object, AlphaTextureChannel);
}
void ULandscapeEditorObject::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorObject.cpp:150
Scope (from outer to inner):
file
function void ULandscapeEditorObject::PostEditChangeProperty
Source code excerpt:
if (PropertyChangedEvent.MemberProperty == nullptr ||
PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(ULandscapeEditorObject, AlphaTexture) ||
PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(ULandscapeEditorObject, AlphaTextureChannel))
{
SetAlphaTexture(AlphaTexture, AlphaTextureChannel);
}
if (PropertyChangedEvent.MemberProperty == nullptr ||
PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(ULandscapeEditorObject, NewLandscape_QuadsPerSection) ||
PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(ULandscapeEditorObject, NewLandscape_SectionsPerComponent) ||
#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorObject.cpp:233
Scope (from outer to inner):
file
function void ULandscapeEditorObject::Load
Source code excerpt:
GConfig->GetFloat(TEXT("LandscapeEdit"), TEXT("WorldSpacePatternBrushSettings.RepeatSize"), WorldSpacePatternBrushSettings.RepeatSize, GEditorPerProjectIni);
FString AlphaTextureName = (AlphaTexture != nullptr) ? AlphaTexture->GetPathName() : FString();
int32 InAlphaTextureChannel = static_cast<int32>(AlphaTextureChannel);
GConfig->GetString(TEXT("LandscapeEdit"), TEXT("AlphaTextureName"), AlphaTextureName, GEditorPerProjectIni);
GConfig->GetInt(TEXT("LandscapeEdit"), TEXT("AlphaTextureChannel"), InAlphaTextureChannel, GEditorPerProjectIni);
AlphaTextureChannel = (ELandscapeTextureColorChannel)InAlphaTextureChannel;
UTexture2D* LoadedTexture = LoadObject<UTexture2D>(nullptr, *AlphaTextureName, nullptr, LOAD_NoWarn);
if ((LoadedTexture == nullptr) && !AlphaTextureName.IsEmpty())
{
UE_LOG(LogLandscapeTools, Error, TEXT("Cannot load alpha texture (%s)"), *AlphaTextureName);
}
SetAlphaTexture(LoadedTexture, AlphaTextureChannel);
int32 InFlattenMode = (int32)ELandscapeToolFlattenMode::Both;
GConfig->GetInt(TEXT("LandscapeEdit"), TEXT("FlattenMode"), InFlattenMode, GEditorPerProjectIni);
FlattenMode = (ELandscapeToolFlattenMode)InFlattenMode;
bool InbUseSlopeFlatten = bUseSlopeFlatten;
#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorObject.cpp:406
Scope (from outer to inner):
file
function void ULandscapeEditorObject::Save
Source code excerpt:
const FString AlphaTextureName = (AlphaTexture != nullptr) ? AlphaTexture->GetPathName() : FString();
GConfig->SetString(TEXT("LandscapeEdit"), TEXT("AlphaTextureName"), *AlphaTextureName, GEditorPerProjectIni);
GConfig->SetInt(TEXT("LandscapeEdit"), TEXT("AlphaTextureChannel"), (int32)AlphaTextureChannel, GEditorPerProjectIni);
GConfig->SetInt(TEXT("LandscapeEdit"), TEXT("FlattenMode"), (int32)FlattenMode, GEditorPerProjectIni);
GConfig->SetBool(TEXT("LandscapeEdit"), TEXT("bUseSlopeFlatten"), bUseSlopeFlatten, GEditorPerProjectIni);
GConfig->SetBool(TEXT("LandscapeEdit"), TEXT("bPickValuePerApply"), bPickValuePerApply, GEditorPerProjectIni);
GConfig->SetBool(TEXT("LandscapeEdit"), TEXT("bUseFlattenTarget"), bUseFlattenTarget, GEditorPerProjectIni);
GConfig->SetFloat(TEXT("LandscapeEdit"), TEXT("FlattenTarget"), FlattenTarget, GEditorPerProjectIni);
#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorObject.cpp:589
Scope (from outer to inner):
file
function void ULandscapeEditorObject::SetAlphaTexture
Source code excerpt:
{
AlphaTexture = nullptr;
AlphaTextureChannel = InTextureChannel;
AlphaTextureSizeX = 0;
AlphaTextureSizeY = 0;
UTexture2D* DefaultAlphaTexture = GetClass()->GetDefaultObject<ULandscapeEditorObject>()->AlphaTexture;
// Try to read the texture data from the specified texture if any :
if (InTexture != nullptr)
{
if (LoadAlphaTextureSourceData(InTexture, AlphaTextureData, AlphaTextureSizeX, AlphaTextureSizeY, AlphaTextureChannel))
{
AlphaTexture = InTexture;
}
else
{
UE_LOG(LogLandscapeTools, Error, TEXT("Invalid source data detected for texture (%s), the default AlphaTexture (%s) will be used."), *InTexture->GetPathName(), DefaultAlphaTexture ? *DefaultAlphaTexture->GetPathName() : TEXT("None"));
#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorObject.cpp:613
Scope (from outer to inner):
file
function void ULandscapeEditorObject::SetAlphaTexture
Source code excerpt:
UE_LOG(LogLandscapeTools, Error, TEXT("No default AlphaTexture specified : the alpha brush won't work as expected."));
}
else if (LoadAlphaTextureSourceData(DefaultAlphaTexture, AlphaTextureData, AlphaTextureSizeX, AlphaTextureSizeY, AlphaTextureChannel))
{
AlphaTexture = DefaultAlphaTexture;
}
else
{
UE_LOG(LogLandscapeTools, Error, TEXT("Invalid source data detected for default AlphaTexture (%s)"), *DefaultAlphaTexture->GetPathName());
#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Public/LandscapeEditorObject.h:673
Scope (from outer to inner):
file
class class ULandscapeEditorObject : public UObject
Source code excerpt:
// Channel of Mask Texture to use
UPROPERTY(Category = "Brush Settings", EditAnywhere, NonTransactional, meta=(DisplayName="Texture Channel", ShowForBrushes="BrushSet_Alpha,BrushSet_Pattern"))
ELandscapeTextureColorChannel AlphaTextureChannel;
UPROPERTY(NonTransactional)
int32 AlphaTextureSizeX;
UPROPERTY(NonTransactional)
int32 AlphaTextureSizeY;
UPROPERTY(NonTransactional)