Navigation
API > API/Plugins > API/Plugins/ModelingComponents
Texture2DBuilder is a utility class for creating/modifying various types of UTexture2D. Use Initialize() functions to configure, can either generate a new UTexture2D (in the Transient package) or modify an existing UTexture2D.
Currently the generated UTexture2D will only have Mip 0, and only Mip 0 can be edited. The generated UTexture2D has format PF_B8G8R8A8 or PF_FloatRGBA.
Use Commit() to lock and update the texture after editing is complete. LockForEditing() can be used to re-open. By default textures are locked for editing on Initialize()
If you have generated a UTexture2D by other means, you can use the static function CopyPlatformDataToSourceData() to populate the Source data from the PlatformData, which is required to save it as a UAsset.
| Name | FTexture2DBuilder |
| Type | class |
| Header File | /Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Public/AssetUtils/Texture2DBuilder.h |
| Include Path | #include "AssetUtils/Texture2DBuilder.h" |
Syntax
class FTexture2DBuilder
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual ~FTexture2DBuilder() |
AssetUtils/Texture2DBuilder.h |
Enums
Public
| Name | Remarks |
|---|---|
| ETextureType | Supported texture types. |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Cancel() |
Cancel active editing and unlock the texture data | AssetUtils/Texture2DBuilder.h | |
void Clear
(
const FFloat16Color& ClearColor |
Clear all texels in the current Mip to the given ClearColor | AssetUtils/Texture2DBuilder.h | |
| Clear all texels in the current Mip to the given ClearColor | AssetUtils/Texture2DBuilder.h | ||
void Clear () |
Clear all texels in the current Mip to the clear/default color for the texture build type | AssetUtils/Texture2DBuilder.h | |
void Commit
(
bool bUpdateSourceData |
Unlock the Mip 0 buffer and update the texture rendering data. | AssetUtils/Texture2DBuilder.h | |
bool Copy
(
const TImageBuilder< FVector4f >& SourceImage, |
Populate texel values from floating-point SourceImage. | AssetUtils/Texture2DBuilder.h | |
bool Copy
(
const TImageBuilder< FVector3f >& SourceImage, |
Populate texel values from floating-point SourceImage | AssetUtils/Texture2DBuilder.h | |
bool CopyImageToSourceData
(
const TImageBuilder< FVector4f >& SourceImage, |
Populate Source Data texel values from a floating point SourceImage | AssetUtils/Texture2DBuilder.h | |
void CopyTexel
(
int64 FromLinearIndex, |
Copy texel value from one linear index to another | AssetUtils/Texture2DBuilder.h | |
bool CopyTo
(
TImageBuilder< FVector4f >& DestImage |
Copy existing texel values to floating-point DestImage. | AssetUtils/Texture2DBuilder.h | |
const FColor & GetClearColor() |
AssetUtils/Texture2DBuilder.h | ||
FFloat16Color GetClearColorFloat16() |
AssetUtils/Texture2DBuilder.h | ||
const FImageDimensions & GetDimensions() |
AssetUtils/Texture2DBuilder.h | ||
void * GetRawTexelBufferUnsafe () |
This point is invalid after the texture is Committed! | AssetUtils/Texture2DBuilder.h | |
const void * GetRawTexelBufferUnsafe () |
This point is invalid after the texture is Committed! | AssetUtils/Texture2DBuilder.h | |
| Get the FColor texel at the given linear index | AssetUtils/Texture2DBuilder.h | ||
| Get the FColor texel at the given X/Y coordinates | AssetUtils/Texture2DBuilder.h | ||
const FFloat16Color & GetTexelFloat16
(
const FVector2i& ImageCoords |
Get the FFloat16Color texel at the given X/Y coordinates | AssetUtils/Texture2DBuilder.h | |
const FFloat16Color & GetTexelFloat16
(
int64 LinearIndex |
Get the FFloat16Color texel at the given linear index | AssetUtils/Texture2DBuilder.h | |
UTexture2D * GetTexture2D() |
AssetUtils/Texture2DBuilder.h | ||
const EPixelFormat GetTexturePixelFormat() |
AssetUtils/Texture2DBuilder.h | ||
const ETextureType GetTextureType() |
AssetUtils/Texture2DBuilder.h | ||
bool Initialize
(
ETextureType BuildTypeIn, |
Create a new UTexture2D configured with the given BuildType and Dimensions | AssetUtils/Texture2DBuilder.h | |
bool Initialize
(
UTexture2D* ExistingTexture, |
Initialize the builder with an existing UTexture2D | AssetUtils/Texture2DBuilder.h | |
bool InitializeAndReplaceExistingTexture
(
UTexture2D* ExistingTexture, |
Create a new UTexture2D 'over' an existing UTexture2D, with the given BuildType and Dimensions | AssetUtils/Texture2DBuilder.h | |
bool InitializeAndReplaceExistingTexture
(
UTexture2D* ExistingTexture, |
Create a new UTexture2D 'over' an existing UTexture2D using the same texture settings as a given source UTexture2D. | AssetUtils/Texture2DBuilder.h | |
const bool IsByteTexture() |
AssetUtils/Texture2DBuilder.h | ||
bool IsEditable() |
AssetUtils/Texture2DBuilder.h | ||
const bool IsFloat16Texture() |
AssetUtils/Texture2DBuilder.h | ||
bool LockForEditing() |
Lock the Mip 0 buffer for editing | AssetUtils/Texture2DBuilder.h | |
| Set the texel at the given linear index to the given FColor | AssetUtils/Texture2DBuilder.h | ||
void SetTexel
(
int64 LinearIndex, |
Set the texel at the given linear index to the given FFloat16Color | AssetUtils/Texture2DBuilder.h | |
void SetTexel
(
const FVector2i& ImageCoords, |
Set the texel at the given X/Y coordinates to the given FFloat16Color | AssetUtils/Texture2DBuilder.h | |
| Set the texel at the given X/Y coordinates to the given FColor | AssetUtils/Texture2DBuilder.h | ||
void UpdateSourceData () |
Copy the current PlatformData to the UTexture2D Source Data. | AssetUtils/Texture2DBuilder.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static UTexture2D * BuildTextureFromImage
(
const TImageBuilder< PixelType >& SourceImage, |
Create a new UTexture2D of the given TextureType from the given SourceImage | AssetUtils/Texture2DBuilder.h | |
static bool CopyPlatformDataToSourceData
(
UTexture2D* Texture, |
Use a FTexture2DBuilder to copy the PlatformData to the UTexture2D Source data, so it can be saved as an Asset | AssetUtils/Texture2DBuilder.h |