UMaterialInstance

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Materials/MaterialInstance.h

Include

#include "Materials/MaterialInstance.h"

Syntax

class UMaterialInstance : public UMaterialInterface

Variables

Name Description

Public variable

FMaterialInstan...

 

BasePropertyOverrides

Public variable

uint8: 1

 

bCastDynamicShadowAsMasked

Public variable

uint8: 1

 

bHasStaticPermutationResource

Indicates whether the instance has static permutation resources (which are required when static parameters are present) Read directly from the rendering thread, can only be modified with the use of a FMaterialUpdateContext.

Public variable

uint8: 1

 

bIsShadingModelFromMaterialExpression

Public variable

TEnumAsByte< EB...

 

BlendMode

Public variable

uint8: 1

 

bOverrideSubsurfaceProfile

Defines if SubsurfaceProfile from this instance is used or it uses the parent one.

Public variable

uint8: 1

 

DitheredLODTransition

Public variable

TArray< struct ...

 

FontParameterValues

Font parameters.

Public variable

float

 

OpacityMaskClipValue

Cached copies of the base property overrides or the value from the parent to avoid traversing the parent chain for each access.

Public variable

UMaterialInterf...

 

Parent

Parent material.

Public variable

TArray< UObject...

 

PermutationTextureReferences

Cached texture references from all expressions in the material (including nested functions).

Public variable

UPhysicalMateri...

 

PhysMaterial

Physical material to use for this graphics material. Used for sounds, effects etc.

Public variable

bool[2]

 

ReentrantFlag

Flag to detect cycles in the material instance graph.

Public variable

FMaterialInstan...

 

Resource

FMaterialRenderProxy derivative that represent this material instance to the renderer, when the renderer needs to fetch parameter values.

Public variable

TArray< struct ...

 

ScalarParameterValues

Scalar parameters.

Public variable

FMaterialShadin...

 

ShadingModels

Public variable

TArray< struct ...

 

TextureParameterValues

Texture parameters.

Public variable

uint8: 1

 

TwoSided

Public variable

TArray< struct ...

 

VectorParameterValues

Vector parameters.

Constructors

Name Description

Public function

UMaterialInstance

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function Static

void

 

AddReferencedObjects

(
    UObject* InThis,
    FReferenceCollector& Collector
)

Public function Static

void

 

AllMaterialsCacheResourceShadersForRendering

(
    bool bUpdateProgressDialog
)

For all materials instances, UMaterialInstance::CacheResourceShadersForRendering.

Public function Virtual

FMaterialRes...

 

AllocatePermutationResource()

Public function

void

 

CacheResourceShadersForCooking

(
    EShaderPlatform ShaderPlatform,
    TArray< FMaterialResource* >&...,
    const ITargetPlatform* TargetP...
)

Cache resource shaders for rendering on the given shader platform.

Protected function

void

 

CacheResourceShadersForRendering()

Cache resource shaders for rendering on the given shader platform.

Protected function

void

 

CacheShadersForResources

(
    EShaderPlatform ShaderPlatform,
    const TArray< FMaterialResource...,
    const ITargetPlatform* TargetP...
)

Caches shader maps for an array of material resources.

Protected function

void

 

ClearParameterValuesInternal

(
    const bool bAllParameters
)

Protected function

void

 

CopyMaterialInstanceParameters

(
    UMaterialInterface* Source
)

Copies over material instance parameters from the base material given a material interface.

Protected function

void

 

CopyMaterialUniformParametersInternal

(
    UMaterialInterface* Source
)

Copies the uniform parameters (scalar, vector and texture) from a material or instance hierarchy.

Public function

void

 

DumpDebugInfo()

Public function Const

bool

 

Equivalent

(
    const UMaterialInstance* Compa...
)

Public function Const

void

 

GetAllParameterInfo

(
    TArray< FMaterialParameterInfo >& ...,
    TArray< FGuid >& OutParameterIds
)

Builds a composited set of parameter names, including inherited and overridden values

Public function

void

 

GetAllShaderMaps

(
    TArray< FMaterialShaderMap* > ...
)

Gathers actively used shader maps from all material resources used by this material instance Note - not refcounting the shader maps so the references must not be used after material resources are modified (compilation, loading, etc)

Protected function Const

void

 

GetAtlasTextureValues

(
    const FMaterialResource* Mater...,
    TArray< UTexture* >& OutTextu...
)

Public function Const

void

 

GetBasePropertyOverridesHash

(
    FSHAHash& OutHash
)

Properties of the base material. Can now be overridden by instances.

Public function Const

bool

 

GetReentrantFlag()

Public function Const

const FStati...

 

GetStaticParameters()

Gets static parameter set for this material.

Public function

void

 

GetStaticParameterValues

(
    FStaticParameterSet& OutStaticPara...
)

Builds a composited set of static parameters, including inherited and overridden values

Protected function Const

void

 

GetTextureExpressionValues

(
    const FMaterialResource* Mater...,
    TArray< UTexture* >& OutTextu...,
    TArray< TArray< int32 > >* Out...
)

Public function Virtual Const

bool

 

HasOverridenBaseProperties()

Protected function

void

 

InitResources()

Initialize the material instance's resources.

Public function

void

 

InitStaticPermutation()

Recompiles static permutations if necessary.

Public function Const

bool

 

IsChildOf

(
    const UMaterialInterface* Mate...
)

Determine whether this Material Instance is a child of another Material

Protected function

void

 

PropagateDataToMaterialProxy()

To share code between PostLoad() and PostEditChangeProperty()

Public function

void

 

SaveShaderStableKeys

(
    const ITargetPlatform* TP
)

Protected function

void

 

SetFontParameterValueInternal

(
    const FMaterialParameterInfo& Para...,
    UFont* FontValue,
    int32 FontPage
)

Protected function

void

 

SetParentInternal

(
    UMaterialInterface* NewParent,
    bool RecacheShaders
)

Public function

void

 

SetReentrantFlag

(
    const bool bValue
)

Protected function

void

 

SetScalarParameterAtlasInternal

(
    const FMaterialParameterInfo& Para...,
    FScalarParameterAtlasInstanceData A...
)

Protected function

bool

 

SetScalarParameterByIndexInternal

(
    int32 ParameterIndex,
    float Value
)

Protected function

void

 

SetScalarParameterValueInternal

(
    const FMaterialParameterInfo& Para...,
    float Value
)

Protected function

void

 

SetTextureParameterValueInternal

(
    const FMaterialParameterInfo& Para...,
    UTexture* Value
)

Protected function

bool

 

SetVectorParameterByIndexInternal

(
    int32 ParameterIndex,
    FLinearColor Value
)

Protected function

void

 

SetVectorParameterValueInternal

(
    const FMaterialParameterInfo& Para...,
    FLinearColor Value
)

Internal interface for setting / updating values for material instances.

Public function

bool

 

UpdateMaterialLayersParameterValue

(
    const FMaterialParameterInfo& Para...,
    const FMaterialLayersFunctions& La...,
    const bool bOverridden,
    const FGuid& GUID
)

Public function

void

 

UpdateOverridableBaseProperties()

Protected function

void

 

UpdateParameterNames()

Refresh parameter names using the stored reference to the expression object for the parameter.

Protected function

bool

 

UpdateParameters()

Updates parameter names on the material instance, returns true if parameters have changed.

Protected function

void

 

UpdatePermutationAllocations

Updates StaticPermutationMaterialResources based on the value of bHasStaticPermutationResource This is a helper used when recompiling MI's with static parameters.

Public function

void

 

UpdateStaticPermutation

(
    const FStaticParameterSet& NewPara...,
    FMaterialUpdateContext* Materi...
)

Sets new static parameter overrides on the instance and recompiles the static permutation resources if needed.

Public function

void

 

UpdateStaticPermutation()

Ensure's static permutations for current parameters and overrides are upto date.

Public function

void

 

UpdateStaticPermutation

(
    const FStaticParameterSet& NewPara...,
    FMaterialInstanceBasePropertyOverri...,
    const bool bForceStaticPermutationU...,
    FMaterialUpdateContext* Materi...
)

Sets new static parameter overrides on the instance and recompiles the static permutation resources if needed (can be forced with bForceRecompile).

Overridden from UMaterialInterface

Name Description

Public function Virtual Const

void

 

AppendReferencedTextures

(
    TArray< UObject* >& InOutText...
)

Appends textures referenced by expressions, including nested functions.

Public function Virtual Const

bool

 

CastsRayTracedShadows()

Public function Virtual

bool

 

CheckMaterialUsage

(
    const EMaterialUsage Usage
)

Checks if the material can be used with the given usage flag.

Public function Virtual Const

bool

 

CheckMaterialUsage_Concurrent

(
    const EMaterialUsage Usage
)

Same as above but is valid to call from any thread.

Public function Virtual

int32

 

CompilePropertyEx

(
    FMaterialCompiler* Compiler,
    const FGuid& AttributeID
)

Allows material properties to be compiled with the option of being overridden by the material attributes input.

Public function Virtual

void

 

ForceRecompileForRendering()

Clears the shader cache and recompiles the shader for rendering.

Public function Virtual Const

void

 

GetAllFontParameterInfo

(
    TArray< FMaterialParameterInfo >& ...,
    TArray< FGuid >& OutParameterIds
)

Public function Virtual Const

void

 

GetAllMaterialLayersParameterInfo

(
    TArray< FMaterialParameterInfo >& ...,
    TArray< FGuid >& OutParameterIds
)

Public function Virtual Const

void

 

GetAllScalarParameterInfo

(
    TArray< FMaterialParameterInfo >& ...,
    TArray< FGuid >& OutParameterIds
)

Public function Virtual Const

void

 

GetAllStaticComponentMaskParameterInfo

(
    TArray< FMaterialParameterInfo >& ...,
    TArray< FGuid >& OutParameterIds
)

Public function Virtual Const

void

 

GetAllStaticSwitchParameterInfo

(
    TArray< FMaterialParameterInfo >& ...,
    TArray< FGuid >& OutParameterIds
)

Public function Virtual Const

void

 

GetAllTextureParameterInfo

(
    TArray< FMaterialParameterInfo >& ...,
    TArray< FGuid >& OutParameterIds
)

Public function Virtual Const

void

 

GetAllVectorParameterInfo

(
    TArray< FMaterialParameterInfo >& ...,
    TArray< FGuid >& OutParameterIds
)

Public function Virtual Const

EBlendMode

 

GetBlendMode()

Public function Virtual Const

bool

 

GetCastShadowAsMasked()

Public function Virtual Const

void

 

GetDependentFunctions

(
    TArray< class UMaterialFunctionInte...
)

Public function Virtual Const

float

 

GetDiffuseBoost()

Public function Virtual Const

float

 

GetEmissiveBoost()

Public function Virtual Const

float

 

GetExportResolutionScale()

Public function Virtual Const

bool

 

GetFontParameterDefaultValue

(
    const FMaterialParameterInfo& Para...,
    UFont*& OutFontValue,
    int32& OutFontPage,
    bool bCheckOwnedGlobalOverrides
)

Public function Virtual Const

bool

 

GetFontParameterValue

(
    const FMaterialParameterInfo& Para...,
    UFont*& OutFontValue,
    int32& OutFontPage,
    bool bOveriddenOnly
)

Public function Virtual Const

bool

 

GetGroupName

(
    const FMaterialParameterInfo& Para...,
    FName& OutGroup
)

Public function Virtual Const

bool

 

GetGroupSortPriority

(
    const FString& InGroupName,
    int32& OutSortPriority
)

Get the sort priority index of the given parameter group

Public function Virtual Const

void

 

GetLightingGuidChain

(
    bool bIncludeTextures,
    TArray< FGuid >& OutGuids
)

Returns all the Guids related to this material.

Public function Virtual Const

const UMater...

 

GetMaterial()

Get the material which we are instancing.

Public function Virtual

UMaterial &#...

 

GetMaterial()

Get the material which we are instancing.

Public function Virtual Const

const UMater...

 

GetMaterial_Concurrent

(
    TMicRecursionGuard& RecursionGuard
)

Public function Virtual Const

bool

 

GetMaterialLayersParameterValue

(
    const FMaterialParameterInfo& Para...,
    FMaterialLayersFunctions& OutLayer...,
    FGuid& OutExpressionGuid,
    bool bCheckParent
)

Get the value of the given static material layers parameter

Public function Virtual

FMaterialRes...

 

GetMaterialResource

(
    ERHIFeatureLevel::Type InFeatureLev...,
    EMaterialQualityLevel::Type Quality...
)

Get the static permutation resource if the instance has one

Public function Virtual Const

const FMater...

 

GetMaterialResource

(
    ERHIFeatureLevel::Type InFeatureLev...,
    EMaterialQualityLevel::Type Quality...
)

Get the static permutation resource if the instance has one

Public function Virtual Const

float

 

GetOpacityMaskClipValue()

Access to overridable properties of the base material.

Public function Virtual Const

bool

 

GetParameterDesc

(
    const FMaterialParameterInfo& Para...,
    FString& OutDesc,
    const TArray< struct FStaticMateria...
)

Public function Virtual Const

bool

 

GetParameterSortPriority

(
    const FMaterialParameterInfo& Para...,
    int32& OutSortPriority,
    const TArray< struct FStaticMateria...
)

Get the sort priority index of the given parameter

Public function Virtual Const

UPhysicalMat...

 

GetPhysicalMaterial()

Return a pointer to the physical material used by this material instance.

Public function Virtual Const

bool

 

GetRefractionSettings

(
    float& OutBiasValue
)

Public function Virtual Const

FMaterialRen...

 

GetRenderProxy()

Return a pointer to the FMaterialRenderProxy used for rendering.

Public function Virtual Const

bool

 

GetScalarParameterDefaultValue

(
    const FMaterialParameterInfo& Para...,
    float& OutValue,
    bool bOveriddenOnly,
    bool bCheckOwnedGlobalOverrides
)

Public function Virtual Const

bool

 

GetScalarParameterSliderMinMax

(
    const FMaterialParameterInfo& Para...,
    float& OutSliderMin,
    float& OutSliderMax
)

Public function Virtual Const

bool

 

GetScalarParameterValue

(
    const FMaterialParameterInfo& Para...,
    float& OutValue,
    bool bOveriddenOnly
)

Public function Virtual Const

FMaterialSha...

 

GetShadingModels()

Public function Virtual Const

bool

 

GetStaticComponentMaskParameterDefaultValue

(
    const FMaterialParameterInfo& Para...,
    bool& OutR,
    bool& OutG,
    bool& OutB,
    bool& OutA,
    FGuid& OutExpressionGuid,
    bool bCheckOwnedGlobalOverrides
)

Public function Virtual Const

bool

 

GetStaticComponentMaskParameterValue

(
    const FMaterialParameterInfo& Para...,
    bool& R,
    bool& G,
    bool& B,
    bool& A,
    FGuid& OutExpressionGuid,
    bool bOveriddenOnly,
    bool bCheckParent
)

Get the value of the given static component mask parameter

Public function Virtual Const

bool

 

GetStaticSwitchParameterDefaultValue

(
    const FMaterialParameterInfo& Para...,
    bool& OutValue,
    FGuid& OutExpressionGuid,
    bool bCheckOwnedGlobalOverrides
)

Public function Virtual Const

bool

 

GetStaticSwitchParameterValue

(
    const FMaterialParameterInfo& Para...,
    bool& OutValue,
    FGuid& OutExpressionGuid,
    bool bOveriddenOnly,
    bool bCheckParent
)

Get the value of the given static switch parameter

Public function Virtual Const

USubsurfaceP...

 

GetSubsurfaceProfile_Internal()

Public function Virtual Const

bool

 

GetTerrainLayerWeightParameterValue

(
    const FMaterialParameterInfo& Para...,
    int32& OutWeightmapIndex,
    FGuid& OutExpressionGuid
)

Get the weightmap index of the given terrain layer weight parameter

Public function Virtual Const

float

 

GetTextureDensity

(
    FName TextureName,
    const FMeshUVChannelInfo& UVChanne...
)

Returns the density of a texture in (LocalSpace Unit / Texture).

Public function Virtual Const

bool

 

GetTextureParameterDefaultValue

(
    const FMaterialParameterInfo& Para...,
    UTexture*& OutValue,
    bool bCheckOwnedGlobalOverrides
)

Public function Virtual Const

bool

 

GetTextureParameterValue

(
    const FMaterialParameterInfo& Para...,
    UTexture*& OutValue,
    bool bOveriddenOnly
)

Public function Virtual

bool

 

GetTexturesInPropertyChain

(
    EMaterialProperty InProperty,
    TArray< UTexture* >& OutTextu...,
    TArray< FName >* OutTexturePar...,
    FStaticParameterSet* InStaticP...,
    ERHIFeatureLevel::Type InFeatureLev...,
    EMaterialQualityLevel::Type InQuali...
)

Get all of the textures in the expression chain for the given property (ie fill in the given array with all textures in the chain).

Public function Virtual Const

void

 

GetUsedTextures

(
    TArray< UTexture* >& OutTextu...,
    EMaterialQualityLevel::Type Quality...,
    bool bAllQualityLevels,
    ERHIFeatureLevel::Type FeatureLevel,
    bool bAllFeatureLevels
)

Return the textures used to render this material.

Public function Virtual Const

void

 

GetUsedTexturesAndIndices

(
    TArray< UTexture* >& OutTextu...,
    TArray< TArray< int32 > >& OutIndi...,
    EMaterialQualityLevel::Type Quality...,
    ERHIFeatureLevel::Type FeatureLevel
)

Return the textures used to render this material and the material indices bound to each.

Public function Virtual Const

bool

 

GetVectorParameterDefaultValue

(
    const FMaterialParameterInfo& Para...,
    FLinearColor& OutValue,
    bool bOveriddenOnly,
    bool bCheckOwnedGlobalOverrides
)

Public function Virtual Const

bool

 

GetVectorParameterValue

(
    const FMaterialParameterInfo& Para...,
    FLinearColor& OutValue,
    bool bOveriddenOnly
)

Public function Virtual

bool

 

IsDependent

(
    UMaterialInterface* TestDepend...
)

Test this material for dependency on a given material.

Public function Virtual Const

bool

 

IsDitheredLODTransition()

Public function Virtual Const

bool

 

IsMasked()

Public function Virtual Const

bool

 

IsPropertyActive

(
    EMaterialProperty InProperty
)

Checks to see if an input property should be active, based on the state of the material

Public function Virtual Const

bool

 

IsScalarParameterUsedAsAtlasPosition

(
    const FMaterialParameterInfo& Para...,
    bool& OutValue,
    TSoftObjectPtr< class UCurveLinearC...,
    TSoftObjectPtr< class UCurveLinearC...
)

Public function Virtual Const

bool

 

IsShadingModelFromMaterialExpression()

Public function Virtual Const

bool

 

IsTwoSided()

Public function Virtual Const

bool

 

IsVectorParameterUsedAsChannelMask

(
    const FMaterialParameterInfo& Para...,
    bool& OutValue
)

Public function Virtual Const

void

 

LogMaterialsAndTextures

(
    FOutputDevice& Ar,
    int32 Indent
)

Output to the log which materials and textures are used by this material.

Public function Virtual

void

 

OverrideScalarParameterDefault

(
    const FMaterialParameterInfo& Para...,
    float Value,
    bool bOverride,
    ERHIFeatureLevel::Type FeatureLevel
)

Public function Virtual

void

 

OverrideTexture

(
    const UTexture* InTextureToOve...,
    UTexture* OverrideTexture,
    ERHIFeatureLevel::Type InFeatureLev...
)

Override a specific texture (transient)

Public function Virtual

void

 

OverrideVectorParameterDefault

(
    const FMaterialParameterInfo& Para...,
    const FLinearColor& Value,
    bool bOverride,
    ERHIFeatureLevel::Type FeatureLevel
)

Overrides the default value of the given parameter (transient).

Public function Virtual Const

void

 

RecacheUniformExpressions

(
    bool bRecreateUniformBuffer
)

Re-caches uniform expressions for this material interface Set bRecreateUniformBuffer to true if uniform buffer layout will change (e.g. FMaterial is being recompiled).

Public function Virtual

void

 

SaveShaderStableKeysInner

(
    const ITargetPlatform* TP,
    const FStableShaderKeyAndValue& Sa...
)

Public function Virtual

bool

 

UpdateLightmassTextureTracking()

Check if the textures have changed since the last time the material was serialized for Lightmass...

Overridden from UObject

Name Description

Public function Virtual

void

 

BeginCacheForCookedPlatformData

(
    const ITargetPlatform* TargetP...
)

Starts caching of platform specific data for the target platform Called when cooking before serialization so that object can prepare platform specific data Not called during normal loading of objects

Public function Virtual

void

 

BeginDestroy()

Called before destroying the object.

Public function Virtual

void

 

ClearAllCachedCookedPlatformData()

Clear all cached cooked platform data

Public function Virtual

void

 

ClearCachedCookedPlatformData

(
    const ITargetPlatform* TargetP...
)

Clears cached cooked platform data for specific platform

Public function Virtual

void

 

FinishDestroy()

Called to finish destroying the object.

Public function Virtual

void

 

GetResourceSizeEx

(
    FResourceSizeEx& CumulativeResourc...
)

Get the size of the object/resource for use in memory tools or to display to artists/LDs in the Editor This is the extended version which separates up the used memory into different memory regions (the actual definition of which may be platform specific).

Public function Virtual

bool

 

IsCachedCookedPlatformDataLoaded

(
    const ITargetPlatform* TargetP...
)

Have we finished loading all the cooked platform data for the target platforms requested in BeginCacheForCookedPlatformData

Public function Virtual

bool

 

IsReadyForFinishDestroy()

Called to check if the object is ready for FinishDestroy.

Public function Virtual

void

 

PostEditChangeProperty

(
    FPropertyChangedEvent& PropertyCha...
)

Called when a property on this object has been modified externally

Public function Virtual

void

 

PostInitProperties()

Called after the C++ constructor and after the properties have been initialized, including those loaded from config.

Public function Virtual

void

 

PostLoad()

Do any object-specific cleanup required immediately after loading an object.

Public function Virtual

void

 

PreSave

(
    const ITargetPlatform* TargetP...
)

Presave function.

Public function Virtual

void

 

Serialize

(
    FArchive& Ar
)

Handles reading, writing, and reference collecting using FArchive.

Typedefs

Name

Description

FCustomParameterSetUpdaterDelegate

Delegate for custom static parameters updater.

FCustomStaticParametersGetterDelegate

Delegate for custom static parameters getter.

Constants

Name

Description

CustomParameterSetUpdaters

An array of custom parameter set updaters.

CustomStaticParametersGetters

Custom static parameters getter delegate.

Deprecated Variables

Name Description

Public variable

bool

 

bOverrideBaseProperties_DEPRECATED

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback