FMaterialUtilities

Material utilities

Windows
MacOS
Linux

Inheritance Hierarchy

IModuleInterface

FMaterialUtilities

References

Module

MaterialUtilities

Header

/Engine/Source/Developer/MaterialUtilities/Public/MaterialUtilities.h

Include

#include "MaterialUtilities.h"

Syntax

class FMaterialUtilities : public IModuleInterface

Remarks

Material utilities

Functions

Name Description

Public function Static

void

 

AnalyzeMaterial

(
    UMaterialInterface* InMaterial,
    const FMaterialProxySettings& InMa...,
    int32& OutNumTexCoords,
    bool& OutRequiresVertexData
)

Analyzes given material to determine how many texture coordinates and whether or not vertex colors are used within the material Graph

Public function Static

void

 

AnalyzeMaterial

(
    UMaterialInterface* InMaterial,
    const TArray< EMaterialProperty >&...,
    int32& OutNumTexCoords,
    bool& OutRequiresVertexData
)

Public function Static

float

 

ComputeRequiredTexelDensityFromDrawDistance

(
    const float InDrawDistance,
    float InWorldSpaceRadius
)

Compute the required texel density needed to properly represent an object/objects covering the provided world space radius

Public function Static

float

 

ComputeRequiredTexelDensityFromScreenSize

(
    const float InScreenSize,
    float InWorldSpaceRadius
)

Compute the required texel density needed to properly represent an object/objects covering the provided world space radius

Public function Static

FFlattenMate...

 

CreateFlattenMaterialWithSettings

(
    const FMaterialProxySettings& InMa...
)

Creates a FFlattenMaterial instance with the given MaterialProxySettings data

Public function Static

UMaterialIns...

 

CreateInstancedMaterial

(
    UMaterialInterface* BaseMateri...,
    UPackage* InOuter,
    const FString& BaseName,
    EObjectFlags Flags
)

Creates an instanced material based of BaseMaterial

Public function Static

UMaterial &#...

 

CreateMaterial

(
    const FFlattenMaterial& InFlattenM...,
    UPackage* InOuter,
    const FString& BaseName,
    EObjectFlags Flags,
    const FMaterialProxySettings& Mate...,
    TArray< UObject* >& OutGenera...,
    const TextureGroup& InTextureGroup
)

Creates UMaterial object from a flatten material

Public function Static

UMaterialInt...

 

CreateProxyMaterialAndTextures

(
    const FString& PackageName,
    const FString& AssetName,
    const FBakeOutput& BakeOutput,
    const FMeshData& MeshData,
    const FMaterialData& MaterialData,
    UMaterialOptions* Options
)

Creates a proxy material and the required texture assets

Public function Static

UMaterialInt...

 

CreateProxyMaterialAndTextures

(
    UPackage* OuterPackage,
    const FString& AssetName,
    const FBakeOutput& BakeOutput,
    const FMeshData& MeshData,
    const FMaterialData& MaterialData,
    UMaterialOptions* Options
)

Creates a proxy material and the required texture assets

Public function Static

UTexture2D &...

 

CreateTexture

(
    UPackage* Outer,
    const FString& AssetLongName,
    FIntPoint Size,
    const TArray< FColor >& Samples,
    TextureCompressionSettings Compress...,
    TextureGroup LODGroup,
    EObjectFlags Flags,
    bool bSRGB,
    const FGuid& SourceGuidHash
)

Generates a texture from an array of samples

Public function Static

void

 

DetermineMaterialImportance

(
    const TArray< UMaterialInterface&#...,
    TArray< float >& OutImportance
)

Calculates an importance value for the given set of materials according to the texture sampler usage

Public function Static

bool

 

ExportBaseColor

(
    ULandscapeComponent* Landscape...,
    int32 TextureSize,
    TArray< FColor >& OutSamples
)

Creates bakes textures for a ULandscapeComponent

Public function Static

bool

 

ExportLandscapeMaterial

(
    ALandscapeProxy* InLandscape,
    const TSet< FPrimitiveComponentId >...,
    FFlattenMaterial& OutFlattenMateri...
)

Flattens specified landscape material

Public function Static

bool

 

ExportMaterialUVDensities

(
    UMaterialInterface* InMaterial,
    EMaterialQualityLevel::Type Quality...,
    ERHIFeatureLevel::Type FeatureLevel,
    FExportErrorManager& OutErrors
)

Get the material texcoord scales applied on each textures

Public function Static

FIntPoint

 

FindMaxTextureSize

(
    UMaterialInterface* InMaterial...,
    FIntPoint MinimumSize
)

End IModuleInterface implementation Iterate through all textures used by the material and return the maximum texture resolution used

Public function Static

void

 

GeneratedBinnedTextureSquares

(
    const FVector2D DestinationSize,
    TArray< float >& InTexureWeights,
    TArray< FBox2D >& OutGeneratedBoxe...
)

Generates a set of texture boxes according to the given weights and final atlas texture size

Public function Static

void

 

OptimizeFlattenMaterial

(
    FFlattenMaterial& InFlattenMateria...
)

Tries to optimize the flatten material's data by picking out constant values for the various properties

Public function Static

void

 

OptimizeSampleArray

(
    TArray< FColor >& InSamples,
    FIntPoint& InSampleSize
)

Tries to optimize the sample array (will set to const value if all samples are equal)

Public function Static

void

 

RemapUniqueMaterialIndices

(
    const TArray< struct FSectionInfo >...,
    const TArray< struct FRawMeshExt > ...,
    const TMap< FIntPoint, TArray< int3...,
    const FMaterialProxySettings& InMa...,
    const bool bBakeVertexData,
    const bool bMergeMaterials,
    TArray< bool >& OutMeshShouldBakeV...,
    TMap< FIntPoint, TArray< int32 > > ...,
    TArray< struct FSectionInfo >& Out...
)

Remaps material indices where possible to reduce the number of materials required for creating a proxy material

Public function Static

void

 

ResizeFlattenMaterial

(
    FFlattenMaterial& InFlattenMateria...,
    const FMeshProxySettings& InMeshPr...
)

Resizes flatten material's data if applicable by comparing it with the original settings

Public function Static

bool

 

SupportsExport

(
    EBlendMode InBlendMode,
    EMaterialProperty InMaterialPropert...
)

Whether material utilities support exporting specified material blend mode and property

Overridden from IModuleInterface

Name Description

Public function Virtual

void

 

ShutdownModule()

Called before the module is unloaded, right before the module object is destroyed.

Public function Virtual

void

 

StartupModule()

Begin IModuleInterface implementation

Classes

Name

Description

Public class

FExportErrorManager

Contains errors generated when exporting material texcoord scales.

Constants

Name

Description

CurrentlyRendering

Flag to indicate whether or not a texture is currently being rendered out

RenderTargetPool

Pool of available render targets, cached for re-using on consecutive property rendering

Deprecated Functions

Name Description

Public function Static

bool

 

ExportMaterial

(
    UMaterialInterface* InMaterial,
    FFlattenMaterial& OutFlattenMateri...,
    FExportMaterialProxyCache* Pro...
)

Please use new functionality in MaterialBaking module

Public function Static

bool

 

ExportMaterial

(
    UWorld* InWorld,
    UMaterialInterface* InMaterial,
    FFlattenMaterial& OutFlattenMateri...
)

Please use ExportMaterial function with new signature

Public function Static

bool

 

ExportMaterialProperty

(
    UMaterialInterface* InMaterial,
    EMaterialProperty InMaterialPropert...,
    FIntPoint InSize,
    TArray< FColor >& OutBMP
)

Please use new functionality in MaterialBaking module

Public function Static

bool

 

ExportMaterialProperty

(
    UMaterialInterface* InMaterial,
    EMaterialProperty InMaterialPropert...,
    TArray< FColor >& OutBMP,
    FIntPoint& OutSize
)

Please use new functionality in MaterialBaking module

Public function Static

bool

 

ExportMaterialProperty

(
    UWorld* InWorld,
    UMaterialInterface* InMaterial,
    EMaterialProperty InMaterialPropert...,
    FIntPoint& OutSize,
    TArray< FColor >& OutBMP
)

Please use ExportMaterialProperty function with new signature

Public function Static

bool

 

ExportMaterialProperty

(
    UWorld* InWorld,
    UMaterialInterface* InMaterial,
    EMaterialProperty InMaterialPropert...,
    UTextureRenderTarget2D* InRend...,
    TArray< FColor >& OutBMP
)

Please use ExportMaterialProperty function with new signature

Public function Static

bool

 

ExportMaterials

(
    TArray< FMaterialMergeData* > ...,
    TArray< FFlattenMaterial* >& ...
)

Please use new functionality in MaterialBaking module