Navigation
API > API/Runtime > API/Runtime/Engine > API/Runtime/Engine/Materials
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- UMaterialInterface
- UMaterialInstance
- UMaterialInstanceConstant
- ULandscapeMaterialInstanceConstant
- UMaterialInstanceDynamic
References
| Module | Engine |
| Header | /Engine/Source/Runtime/Engine/Classes/Materials/MaterialInstance.h |
| Include | #include "Materials/MaterialInstance.h" |
Syntax
class UMaterialInstance : public UMaterialInterface
Variables
| Type | Name | Description | |
|---|---|---|---|
| FMaterialInstanceBasePropertyOverrides | BasePropertyOverrides | ||
| uint8: 1 | bCastDynamicShadowAsMasked | ||
| bool | bDisallowStaticParameterPermutations | Whether static parameter permutations should be disabled (e.g. due to having a restricted parent material) | |
| 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. | |
| uint8: 1 | bIsShadingModelFromMaterialExpression | ||
| uint8: 1 | bIsThinSurface | ||
| TEnumAsByte< EBlendMode > | BlendMode | ||
| uint8: 1 | bLoadedCachedData | ||
| uint8: 1 | bOutputTranslucentVelocity | ||
| uint8: 1 | bOverrideSubsurfaceProfile | Defines if SubsurfaceProfile from this instance is used or it uses the parent one. | |
| TUniquePtr< FMaterialInstanceCachedData > | CachedData | ||
| FDisplacementScaling | DisplacementScaling | ||
| uint8: 1 | DitheredLODTransition | ||
| TArray< struct FDoubleVectorParameterValue > | DoubleVectorParameterValues | DoubleVector parameters. | |
| TArray< struct FFontParameterValue > | FontParameterValues | Font parameters. | |
| float | MaxWorldPositionOffsetDisplacement | ||
| FMaterialOverrideNanite | NaniteOverrideMaterial | An override material which will be used instead of this one when rendering with Nanite. | |
| float | OpacityMaskClipValue | Cached copies of the base property overrides or the value from the parent to avoid traversing the parent chain for each access. | |
| TObjectPtr< class UMaterialInterface > | Parent | Parent material. | |
| TObjectPtr< class UPhysicalMaterial >[EPhysicalMaterialMaskColor::MAX] | PhysicalMaterialMap | Physical material map used with physical material mask, when it exists. | |
| TObjectPtr< class UPhysicalMaterial > | PhysMaterial | Physical material to use for this graphics material. Used for sounds, effects etc. | |
| bool[2] | ReentrantFlag | Flag to detect cycles in the material instance graph, this is only used at content creation time where the hierarchy can be changed. | |
| FMaterialInstanceResource * | Resource | FMaterialRenderProxy derivative that represent this material instance to the renderer, when the renderer needs to fetch parameter values. | |
| TArray< struct FRuntimeVirtualTextureParameterValue > | RuntimeVirtualTextureParameterValues | RuntimeVirtualTexture parameters. | |
| TArray< struct FScalarParameterValue > | ScalarParameterValues | Scalar parameters. | |
| FMaterialShadingModelField | ShadingModels | ||
| TArray< struct FSparseVolumeTextureParameterValue > | SparseVolumeTextureParameterValues | Sparse Volume Texture parameters. | |
| TArray< struct FTextureParameterValue > | TextureParameterValues | Texture parameters. | |
| uint8: 1 | TwoSided | ||
| TArray< struct FVectorParameterValue > | VectorParameterValues | Vector parameters. |
Constructors
| Type | Name | Description | |
|---|---|---|---|
UMaterialInstance
(
const FObjectInitializer& ObjectInitializer |
Destructors
| Type | Name | Description | |
|---|---|---|---|
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | AddParameterValueInternal
(
const FMaterialParameterInfo& ParameterInfo, |
||
| void | AddReferencedObjects
(
UObject* InThis, |
||
| void | AllMaterialsCacheResourceShadersForRendering
(
bool bUpdateProgressDialog, |
For all materials instances, UMaterialInstance::CacheResourceShadersForRendering. | |
| FMaterialResource * | |||
| void | |||
| void | BeginCacheShadersForResources
(
EShaderPlatform ShaderPlatform, |
Initiates caching for this shader resource that will be finished when each material resource IsCompilationFinished returns true. | |
| void | CacheResourceShadersForCooking
(
EShaderPlatform ShaderPlatform, |
Cache resource shaders for rendering on the given shader platform. | |
| void | CacheResourceShadersForRendering
(
EMaterialShaderPrecompileMode PrecompileMode, |
Cache resource shaders for rendering on the given shader platform. | |
| void | CacheResourceShadersForRendering
(
EMaterialShaderPrecompileMode PrecompileMode |
Cache resource shaders for rendering on the given shader platform. | |
| void | CacheShadersForResources
(
EShaderPlatform ShaderPlatform, |
Caches shader maps for an array of material resources. | |
| void | ClearParameterValuesInternal
(
EMaterialInstanceClearParameterFlag Flags |
||
| void | CopyMaterialInstanceParameters
(
UMaterialInterface* Source |
Copies over material instance parameters from the base material given a material interface. | |
| void | Copies the uniform parameters (scalar, vector and texture) from a material or instance hierarchy. | ||
| void | DeclareConstructClasses
(
TArray< FTopLevelAssetPath >& OutConstructClasses, |
||
| void | |||
| bool | Equivalent
(
const UMaterialInstance* CompareTo |
||
| void | |||
| void | GetAllShaderMaps
(
TArray< FMaterialShaderMap* >& OutShaderMaps |
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) | |
| void | GetBasePropertyOverridesHash
(
FSHAHash& OutHash |
Properties of the base material. Can now be overridden by instances. | |
| FString | |||
| const FMaterialInstanceCachedData & | |||
| const FStaticParameterSetEditorOnlyData & | |||
| bool | GetParameterOverrideValue
(
EMaterialParameterType Type, |
||
| bool | GetReentrantFlag
(
bool bIsInGameThread |
||
| FStaticParameterSet | |||
| void | GetTextureExpressionValues
(
const FMaterialResource* MaterialResource, |
||
| bool | |||
| bool | Gets static parameter set for this material. | ||
| void | Initialize the material instance's resources. | ||
| void | InitStaticPermutation
(
EMaterialShaderPrecompileMode PrecompileMode |
Recompiles static permutations if necessary. | |
| bool | IsChildOf
(
const UMaterialInterface* Material |
Determine whether this Material Instance is a child of another Material | |
| bool | IsRedundant () |
Returns true if using this material instance would be equivalent to using its parent. | |
| bool | IsStaticPermutationAllowedForCandidateParent
(
UMaterialInterface* CandidateParent |
Returns this material instance is allowed to override static parameters and introduce a new shader permutation when it derives from `CandidateParent_. | |
| FGraphEventArray | PrecachePSOs
(
const FPSOPrecacheVertexFactoryDataList& VertexFactoryDataList, |
||
| void | To share code between PostLoad() and PostEditChangeProperty() | ||
| void | RemoveLayerParameterIndex
(
int32 Index |
||
| void | ReserveParameterValuesInternal
(
EMaterialParameterType Type, |
Internal interface for setting / updating values for material instances. | |
| void | SaveShaderStableKeys
(
const ITargetPlatform* TP |
||
| void | SetDoubleVectorParameterValueInternal
(
const FMaterialParameterInfo& ParameterInfo, |
||
| void | SetFontParameterValueInternal
(
const FMaterialParameterInfo& ParameterInfo, |
||
| bool | SetMaterialLayers
(
const FMaterialLayersFunctions& LayersValue |
||
| void | SetParameterValueInternal
(
const FMaterialParameterInfo& ParameterInfo, |
||
| bool | SetParentInternal
(
UMaterialInterface* NewParent, |
||
| void | SetReentrantFlag
(
const bool bValue, |
||
| void | SetRuntimeVirtualTextureParameterValueInternal
(
const FMaterialParameterInfo& ParameterInfo, |
||
| void | SetScalarParameterAtlasInternal
(
const FMaterialParameterInfo& ParameterInfo, |
||
| bool | SetScalarParameterByIndexInternal
(
int32 ParameterIndex, |
||
| void | SetScalarParameterValueInternal
(
const FMaterialParameterInfo& ParameterInfo, |
||
| void | SetSparseVolumeTextureParameterValueInternal
(
const FMaterialParameterInfo& ParameterInfo, |
||
| void | SetStaticSwitchParameterValueEditorOnly
(
const FMaterialParameterInfo& ParameterInfo, |
||
| void | SetTextureParameterValueInternal
(
const FMaterialParameterInfo& ParameterInfo, |
||
| bool | SetVectorParameterByIndexInternal
(
int32 ParameterIndex, |
||
| void | SetVectorParameterValueInternal
(
const FMaterialParameterInfo& ParameterInfo, |
||
| void | Tracking of in-flight uniform expression cache update operations for the material instance, for thread safety destroying the resource. | ||
| void | SwapLayerParameterIndices
(
int32 OriginalIndex, |
||
| void | |||
| void | |||
| void | Refresh parameter names using the stored reference to the expression object for the parameter. | ||
| bool | Updates parameter names on the material instance, returns true if parameters have changed. | ||
| void | UpdateStaticPermutation
(
const FStaticParameterSet& NewParameters, |
Sets new static parameter overrides on the instance and recompiles the static permutation resources if needed. | |
| void | UpdateStaticPermutation
(
FMaterialUpdateContext* MaterialUpdateContext |
Ensure's static permutations for current parameters and overrides are upto date. | |
| void | UpdateStaticPermutation
(
const FStaticParameterSet& NewParameters, |
Sets new static parameter overrides on the instance and recompiles the static permutation resources if needed (can be forced with bForceRecompile). | |
| void | Ensures that current parent is a valid for this material instance and if not, it resets the parent to null. | ||
| void | ValidateTextureOverrides
(
ERHIFeatureLevel::Type InFeatureLevel |
Overridden from UMaterialInterface
| Type | Name | Description | |
|---|---|---|---|
| void | CacheGivenTypesForCooking
(
EShaderPlatform Platform, |
||
| void | CacheShaders
(
EMaterialShaderPrecompileMode CompileMode |
Submits remaining shaders for recompilation. | |
| bool | |||
| bool | CheckMaterialUsage
(
const EMaterialUsage Usage |
Checks if the material can be used with the given usage flag. | |
| bool | CheckMaterialUsage_Concurrent
(
const EMaterialUsage Usage |
Same as above but is valid to call from any thread. | |
| int32 | CompilePropertyEx
(
FMaterialCompiler* Compiler, |
Allows material properties to be compiled with the option of being overridden by the material attributes input. | |
| void | DumpDebugInfo
(
FOutputDevice& OutputDevice |
||
| void | Clears the shader cache and recompiles the shader for rendering. | ||
| void | GetAllParametersOfType
(
EMaterialParameterType Type, |
||
| EBlendMode | GetBlendMode () |
||
| const FMaterialCachedExpressionData & | GetCachedExpressionData
(
TMicRecursionGuard RecursionGuard |
||
| const FMaterialCachedHLSLTree & | GetCachedHLSLTree
(
TMicRecursionGuard RecursionGuard |
||
| bool | |||
| bool | |||
| void | GetDependencies
(
TSet< UMaterialInterface* >& Dependencies |
Get this material dependencies. | |
| void | GetDependentFunctions
(
TArray< class UMaterialFunctionInterface* >& DependentFunctions |
||
| float | |||
| FDisplacementScaling | |||
| UMaterialInstanceEditorOnlyData * | |||
| const UMaterialInstanceEditorOnlyData * | |||
| const UClass * | |||
| float | |||
| float | |||
| bool | GetGroupSortPriority
(
const FString& InGroupName, |
Get the sort priority index of the given parameter group | |
| void | GetLightingGuidChain
(
bool bIncludeTextures, |
Returns all the Guids related to this material. | |
| const UMaterial * | GetMaterial () |
Get the material which we are instancing. | |
| UMaterial * | GetMaterial () |
Get the material which we are instancing. | |
| const UMaterial * | GetMaterial_Concurrent
(
TMicRecursionGuard RecursionGuard |
Same as above, but can be called concurrently | |
| void | GetMaterialInheritanceChain
(
FMaterialInheritanceChain& OutChain |
||
| bool | GetMaterialLayers
(
FMaterialLayersFunctions& OutLayers, |
Get the material layers stack | |
| const FMaterialResource * | GetMaterialResource
(
ERHIFeatureLevel::Type InFeatureLevel, |
Get the static permutation resource if the instance has one | |
| FMaterialResource * | GetMaterialResource
(
ERHIFeatureLevel::Type InFeatureLevel, |
Get the static permutation resource if the instance has one | |
| float | |||
| UMaterialInterface * | GetNaniteOverride
(
TMicRecursionGuard RecursionGuard |
Get the associated nanite override material | |
| float | Access to overridable properties of the base material. | ||
| bool | GetParameterValue
(
EMaterialParameterType Type, |
||
| UPhysicalMaterial * | Return a pointer to the physical material used by this material instance. | ||
| UPhysicalMaterial * | GetPhysicalMaterialFromMap
(
int32 Index |
Return a pointer to the physical material from mask map at given index. | |
| UPhysicalMaterialMask * | Return a pointer to the physical material mask used by this material instance. | ||
| void | GetReferencedTexturesAndOverrides
(
TSet< const UTexture* >& InOutTextures |
Add to the set any texture referenced by expressions, including nested functions, as well as any overrides from parameters. | |
| bool | GetRefractionSettings
(
float& OutBiasValue |
||
| FMaterialRenderProxy * | Return a pointer to the FMaterialRenderProxy used for rendering. | ||
| void | GetShaderTypes
(
EShaderPlatform Platform, |
Gathers a list of shader types sorted by vertex factory types that should be cached for this material. | |
| FMaterialShadingModelField | |||
| USubsurfaceProfile * | |||
| float | GetTextureDensity
(
FName TextureName, |
Returns the density of a texture in (LocalSpace Unit / Texture). | |
| bool | GetTextureParameterValue
(
const FHashedMaterialParameterInfo& ParameterInfo, |
||
| bool | GetTexturesInPropertyChain
(
EMaterialProperty InProperty, |
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). | |
| void | GetUsedTextures
(
TArray< UTexture* >& OutTextures, |
Return the textures used to render this material. | |
| void | GetUsedTexturesAndIndices
(
TArray< UTexture* >& OutTextures, |
Return the textures used to render this material and the material indices bound to each. | |
| bool | IsComplete () |
Checks to see if this material has all its shaders cached. | |
| bool | IsDependent
(
UMaterialInterface* TestDependency |
Test this material for dependency on a given material. | |
| bool | IsDependent_Concurrent
(
UMaterialInterface* TestDependency, |
Same as above, but can be called concurrently | |
| bool | |||
| bool | IsMasked () |
||
| bool | IsPropertyActive
(
EMaterialProperty InProperty |
Checks to see if an input property should be active, based on the state of the material | |
| bool | |||
| bool | |||
| bool | |||
| bool | IsTwoSided () |
||
| bool | IterateDependentFunctions
(
TFunctionRef< bool(UMaterialFunctionInterface*)> Predicate |
||
| void | LogMaterialsAndTextures
(
FOutputDevice& Ar, |
Output to the log which materials and textures are used by this material. | |
| void | OverrideNumericParameterDefault
(
EMaterialParameterType Type, |
Overrides the default value of the given parameter (transient). | |
| void | OverrideTexture
(
const UTexture* InTextureToOverride, |
Override a specific texture (transient) | |
| 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). | |
| void | SaveShaderStableKeysInner
(
const ITargetPlatform* TP, |
||
| bool | |||
| bool | Check if the textures have changed since the last time the material was serialized for Lightmass... | ||
| bool |
Overridden from UObject
| Type | Name | Description | |
|---|---|---|---|
| void | BeginCacheForCookedPlatformData
(
const ITargetPlatform* TargetPlatform |
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 | |
| void | BeginDestroy () |
Called before destroying the object. | |
| void | Clear all cached cooked platform data | ||
| void | ClearCachedCookedPlatformData
(
const ITargetPlatform* TargetPlatform |
Clears cached cooked platform data for specific platform | |
| void | Called to finish destroying the object. | ||
| void | GetResourceSizeEx
(
FResourceSizeEx& CumulativeResourceSize |
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). | |
| bool | IsCachedCookedPlatformDataLoaded
(
const ITargetPlatform* TargetPlatform |
Have we finished loading all the cooked platform data for the target platforms requested in BeginCacheForCookedPlatformData | |
| bool | Called to check if the object is ready for FinishDestroy. | ||
| void | PostEditChangeProperty
(
FPropertyChangedEvent& PropertyChangedEvent |
Called when a property on this object has been modified externally | |
| void | PostEditUndo () |
Called after applying a transaction to the object. | |
| void | Called after the C++ constructor and after the properties have been initialized, including those loaded from config. | ||
| void | PostLoad () |
Do any object-specific cleanup required immediately after loading an object. | |
| void | PreSave
(
FObjectPreSaveContext SaveContext |
Presave function. | |
| void | Handles reading, writing, and reference collecting using FArchive. |
Deprecated Variables
| Type | Name | Description | |
|---|---|---|---|
| bool | bOverrideBaseProperties_DEPRECATED |
Deprecated Functions
| Type | Name | Description | |
|---|---|---|---|
| PRAGMA_DISABLE_DEPRECATION_WARNINGSvoid | PreSave
(
const ITargetPlatform* TargetPlatform |
Use version that takes FObjectPreSaveContext instead. | |
| void | UpdatePermutationAllocations
(
FMaterialResourceDeferredDeletionArray* ResourcesToFree |
Calling UpdatePermutationAllocations is no longer necessary |