FMaterial

[FMaterial](API\Runtime\Engine\FMaterial) serves 3 intertwined purposes: Represents a material to the material compilation process, and provides hooks for extensibility (CompileProperty, etc) Represents a material to the renderer, with functions to access material properties Stores a cached shader map, and other transient output from a compile, which is necessary with async shader compiling (when a material finishes async compilation, the shader map and compile errors need to be stored somewhere)

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Public/MaterialShared.h

Include

#include "MaterialShared.h"

Syntax

class FMaterial

Remarks

FMaterial serves 3 intertwined purposes: Represents a material to the material compilation process, and provides hooks for extensibility (CompileProperty, etc) Represents a material to the renderer, with functions to access material properties Stores a cached shader map, and other transient output from a compile, which is necessary with async shader compiling (when a material finishes async compilation, the shader map and compile errors need to be stored somewhere)

Variables

Name Description

Public variable

FUniformParamet...

 

TransientOverrides

Constructors

Name Description

Public function

FMaterial()

Minimal initialization constructor.

Destructors

Name Description

Public function Virtual

~FMaterial()

Destructor

Functions

Name Description

Public function Static

void

 

AddEditorLoadedMaterialResource

(
    FMaterial* Material
)

Adds an FMaterial to the global list.

Public function Virtual

void

 

AddReferencedObjects

(
    FReferenceCollector& Collector
)

Public function Virtual Const

bool

 

AllowNegativeEmissiveColor()

Public function Static

void

 

BackupEditorLoadedMaterialShadersToMemory

(
    TMap< FMaterialShaderMap*, TUn...
)

Backs up any FShaders in editor loaded materials to memory through serialization and clears FShader references.

Public function Virtual

void

 

BeginAllowCachingStaticParameterValues()

Public function

bool

 

CacheShaders

(
    EShaderPlatform Platform,
    const ITargetPlatform* TargetP...
)

Caches the material shaders for this material on the given platform.

Public function

bool

 

CacheShaders

(
    const FMaterialShaderMapId& Shader...,
    EShaderPlatform Platform,
    const ITargetPlatform* TargetP...
)

Caches the material shaders for the given static parameter set and platform.

Public function

void

 

CancelCompilation()

Cancels all outstanding compilation jobs for this material.

Public function Virtual Const

bool

 

CastsRayTracedShadows()

Protected function Const

int32

 

CompilePropertyAndSetMaterialProperty

(
    EMaterialProperty Property,
    FMaterialCompiler* Compiler,
    EShaderFrequency OverrideShaderFreq...,
    bool bUsePreviousFrameTime
)

Entry point for compiling a specific material property. This must call SetMaterialProperty.

Public function Virtual Const

bool

 

ComputeFogPerPixel()

Public function

void

 

DiscardShaderMap()

Discards loaded shader maps if the application can't render

Public function

void

 

DumpDebugInfo()

Public function Virtual

void

 

EndAllowCachingStaticParameterValues()

Public function

void

 

FinishCompilation()

Blocks until compilation has completed. Returns immediately if a compilation is not outstanding.

Protected function Virtual Const

void

 

GatherCustomOutputExpressions

(
    TArray< class UMaterialExpressionCu...
)

Gather any UMaterialExpressionCustomOutput expressions they can be compiled in turn

Protected function Virtual Const

void

 

GatherExpressionsForCustomInterpolators

(
    TArray< class UMaterialExpression&...
)

Gather any UMaterialExpressionCustomOutput expressions in the material and referenced function calls

Public function Virtual Const

bool

 

GetAllowDevelopmentShaderCompile()

Returns true if this material is allowed to make development shaders via the global CVar CompileShadersForDevelopment.

Protected function Virtual Const

FString

 

GetBaseMaterialPathName()

Useful for debugging.

Public function Virtual Const

int32

 

GetBlendableLocation()

Public function Virtual Const

bool

 

GetBlendableOutputAlpha()

Public function Const

enum EBlendM...

 

GetBlendMode()

Public function Const

bool

 

GetCastDynamicShadowAsMasked()

Public function Const

const TArray...

 

GetCompileErrors()

Protected function Virtual Const

FString

 

GetDebugName()

Public function Virtual Const

uint32

 

GetDecalBlendMode()

Protected function Const

void

 

GetDependentShaderAndVFTypes

(
    EShaderPlatform Platform,
    TArray< FShaderType* >& OutSh...,
    TArray< const FShaderPipelineType&...,
    TArray< FVertexFactoryType* > ...
)

Produces arrays of any shader and vertex factory type that this material is dependent on.

Public function Const

const TArray...

 

GetErrorExpressions()

Public function Const

const FStati...

 

GetFeatureLevel()

Public function Const

FString

 

GetFriendlyName()

Public function Const

FMaterialSha...

 

GetGameThreadShaderMap()

Public function Const

const FGuid ...

 

GetLegacyId()

Protected function Const

bool

 

GetLoadedCookedShaderMapId()

Public function Virtual Const

uint32

 

GetMaterialDecalResponse()

Public function Const

EMaterialDom...

 

GetMaterialDomain()

Public function

bool

 

GetMaterialExpressionSource

(
    FString& OutSource
)

Get user source code for the material, with a list of code snippets to highlight representing the code for each MaterialExpression

Protected function Const

FGuid

 

GetMaterialId()

Gets the Guid that represents this material.

Public function Virtual Const

UMaterialInt...

 

GetMaterialInterface()

Public function Virtual Const

EMaterialSha...

 

GetMaterialShaderMapUsage()

Returns which shadermap this material is bound to.

Public function Const

FString

 

GetMaterialUsageDescription()

Returns a string that describes the material's usage for debugging purposes.

Public function Virtual Const

float

 

GetMaxDisplacement()

Public function Virtual Const

int32

 

GetNumCustomizedUVs()

Public function Const

float

 

GetOpacityMaskClipValue()

Public function Const

EMaterialQua...

 

GetQualityLevel()

Public function Const

TArrayView< ...

 

GetReferencedTextures()

Public function Virtual Const

float

 

GetRefractionDepthBiasValue()

Public function Virtual Const

enum ERefrac...

 

GetRefractionMode()

Public function Const

FMaterialSha...

 

GetRenderingThreadShaderMap()

Public function Const

uint8

 

GetRuntimeVirtualTextureOutputAttibuteMask_RenderThread()

Get the runtime virtual texture output attribute mask for the material.

Public function Const

TShaderRef< ...

 

GetShader

(
    FVertexFactoryType* VertexFact...,
    const typename ShaderType::FPermuta...,
    bool bFatalIfMissing
)

Finds the shader matching the template type and the passed in vertex factory, asserts if not found.

Public function Const

TShaderRef< ...

 

GetShader

(
    FVertexFactoryType* VertexFact...,
    int32 PermutationId,
    bool bFatalIfMissing
)

Public function Virtual Const

void

 

GetShaderMapId

(
    EShaderPlatform Platform,
    FMaterialShaderMapId& OutId
)

Material properties.

Protected function

void

 

GetShaderMapIDsWithUnfinishedCompilation

(
    TArray< int32 >& ShaderMapIds
)

Fills the passed array with IDs of shader maps unfinished compilation jobs.

Protected function Const

const FMater...

 

GetShaderMapToUse()

Shared code needed for GetUniformScalarParameterExpressions, GetUniformVectorParameterExpressions, GetUniformCubeTextureExpressions..

Protected function Virtual Const

EMaterialSha...

 

GetShaderMapUsage()

Gets the shader map usage of the material, which will be included in the DDC key.

Public function Const

FShaderPipel...

 

GetShaderPipeline

(
    FShaderPipelineType* ShaderPip...,
    FVertexFactoryType* VertexFact...,
    bool bFatalIfNotFound
)

Public function Const

FMaterialSha...

 

GetShadingModels()

Public function Virtual Const

void

 

GetStaticParameterSet

(
    EShaderPlatform Platform,
    FStaticParameterSet& OutSet
)

Public function Virtual Const

uint32

 

GetStencilCompare()

Public function Virtual Const

uint32

 

GetStencilRefValue()

Public function Virtual Const

enum EMateri...

 

GetTessellationMode()

Public function Virtual Const

float

 

GetTranslucencyDirectionalLightingIntensity()

Public function Virtual Const

enum ETransl...

 

GetTranslucencyLightingMode()

Public function Virtual Const

float

 

GetTranslucentBackscatteringExponent()

Public function Virtual Const

FLinearColor

 

GetTranslucentMultipleScatteringExtinction()

Public function Virtual Const

float

 

GetTranslucentSelfShadowDensityScale()

Public function Virtual Const

float

 

GetTranslucentSelfShadowSecondDensityScale()

Public function Virtual Const

float

 

GetTranslucentSelfShadowSecondOpacity()

Public function Virtual Const

float

 

GetTranslucentShadowDensityScale()

Public function Virtual Const

float

 

GetTranslucentShadowStartOffset()

Public function Const

const TArray...

 

GetUniform2DArrayTextureExpressions()

Public function Const

const TArray...

 

GetUniform2DTextureExpressions()

Public function Const

const TArray...

 

GetUniformCubeTextureExpressions()

Public function Const

const FUnifo...

 

GetUniformExpressions()

Accessors.

Public function Const

const TArray...

 

GetUniformScalarParameterExpressions()

Public function Const

const TArray...

 

GetUniformTextureExpressions

Public function Const

const TArray...

 

GetUniformVectorParameterExpressions()

Public function Const

const TArray...

 

GetUniformVirtualTextureExpressions()

Public function Const

const TArray...

 

GetUniformVolumeTextureExpressions()

Public function Const

bool

 

GetUsesDynamicParameter()

Public function Virtual Const

bool

 

HasBaseColorConnected()

Public function Virtual Const

bool

 

HasEmissiveColorConnected()

Public function Virtual Const

bool

 

HasMaterialAttributesConnected()

Public function Virtual Const

bool

 

HasNormalConnected()

Public function Virtual Const

bool

 

HasPixelDepthOffsetConnected()

Public function Virtual Const

bool

 

HasRoughnessConnected()

Public function Virtual Const

bool

 

HasRuntimeVirtualTextureOutput()

Public function Virtual Const

bool

 

HasSpecularConnected()

Public function Const

bool

 

HasValidGameThreadShaderMap()

Checks if there is a valid GameThreadShaderMap, that is, the material can be rendered as intended.

Public function Virtual Const

bool

 

HasVertexPositionOffsetConnected()

Public function Virtual Const

bool

 

IsAdaptiveTessellationEnabled()

Public function Const

bool

 

IsCompilationFinished()

Checks if the compilation for this shader is finished

Public function Virtual Const

bool

 

IsCrackFreeDisplacementEnabled()

Public function Virtual Const

bool

 

IsDefaultMaterial()

Public function Const

bool

 

IsDeferredDecal()

Public function Virtual Const

bool

 

IsDistorted()

Public function Const

bool

 

IsDitheredLODTransition()

Public function Virtual Const

bool

 

IsDitherMasked()

Public function Virtual Const

bool

 

IsDualBlendingEnabled

(
    EShaderPlatform Platform
)

Public function Virtual Const

bool

 

IsFullyRough()

Public function Const

bool

 

IsLightFunction()

Public function Const

bool

 

IsMasked()

Public function Virtual Const

bool

 

IsMobileSeparateTranslucencyEnabled()

Public function Virtual Const

bool

 

IsNonmetal()

Public function Const

bool

 

IsPersistent()

Should shaders compiled for this material be saved to disk?

Public function Const

bool

 

IsShadingModelFromMaterialExpression()

Public function Virtual Const

bool

 

IsSky()

Public function Const

bool

 

IsSpecialEngineMaterial()

Public function Virtual Const

bool

 

IsStencilTestEnabled()

Public function Virtual Const

bool

 

IsTangentSpaceNormal()

Public function Virtual Const

bool

 

IsTranslucencyAfterDOFEnabled()

Public function Virtual Const

bool

 

IsTranslucencyWritingCustomDepth()

Public function Virtual Const

bool

 

IsTranslucencyWritingVelocity()

Public function Const

bool

 

IsTwoSided()

Public function Virtual Const

bool

 

IsUIMaterial()

Public function Virtual Const

bool

 

IsUsedWithAPEXCloth()

Public function Virtual Const

bool

 

IsUsedWithBeamTrails()

Public function Virtual Const

bool

 

IsUsedWithEditorCompositing()

Public function Virtual Const

bool

 

IsUsedWithGeometryCache()

Public function Virtual Const

bool

 

IsUsedWithGeometryCollections()

Public function Virtual Const

bool

 

IsUsedWithHairStrands()

Public function Virtual Const

bool

 

IsUsedWithInstancedStaticMeshes()

Public function Virtual Const

bool

 

IsUsedWithLandscape()

Public function Virtual Const

bool

 

IsUsedWithLidarPointCloud()

Public function Virtual Const

bool

 

IsUsedWithMeshParticles()

Public function Virtual Const

bool

 

IsUsedWithMorphTargets()

Public function Virtual Const

bool

 

IsUsedWithNiagaraMeshParticles()

Public function Virtual Const

bool

 

IsUsedWithNiagaraRibbons()

Public function Virtual Const

bool

 

IsUsedWithNiagaraSprites()

Public function Virtual Const

bool

 

IsUsedWithParticleSprites()

Public function Virtual Const

bool

 

IsUsedWithParticleSystem()

Public function Virtual Const

bool

 

IsUsedWithSkeletalMesh()

Public function Virtual Const

bool

 

IsUsedWithSplineMeshes()

Public function Virtual Const

bool

 

IsUsedWithStaticLighting()

Public function Virtual Const

bool

 

IsUsedWithUI()

Public function Virtual Const

bool

 

IsUsedWithWater()

Public function Virtual Const

bool

 

IsUsingFullPrecision()

Public function Virtual Const

bool

 

IsUsingHQForwardReflections()

Public function Virtual Const

bool

 

IsUsingPlanarForwardReflections()

Public function Virtual Const

bool

 

IsUsingPreintegratedGFForSimpleIBL()

Public function Const

bool

 

IsVolumetricPrimitive()

Public function Const

bool

 

IsWireframe()

Public function Virtual

void

 

LegacySerialize

(
    FArchive& Ar
)

Serializes the material.

Public function Const

bool

 

MaterialMayModifyMeshPosition()

Note: This function is only intended for use in deciding whether or not shader permutations are required before material translation occurs.

Public function Const

bool

 

MaterialModifiesMeshPosition_GameThread()

Public function Const

bool

 

MaterialModifiesMeshPosition_RenderThread()

Does the material modify the mesh position.

Public function Const

bool

 

MaterialUsesDistanceCullFade_GameThread()

Does the material use a distance cull fade.

Public function Const

bool

 

MaterialUsesPixelDepthOffset()

Does the material use a pixel depth offset.

Public function Const

bool

 

MaterialUsesSceneDepthLookup_GameThread()

Public function Const

bool

 

MaterialUsesSceneDepthLookup_RenderThread()

Does the material use a SceneDepth lookup.

Public function Const

bool

 

NeedsGBuffer()

Public function Const

bool

 

NeedsSceneTextures()

Public function Virtual

void

 

NotifyCompilationFinished()

Called when compilation of an FMaterial finishes, after the GameThreadShaderMap is set and the render command to set the RenderThreadShaderMap is queued

Public function

void

 

RegisterInlineShaderMap

(
    bool bLoadedByCookedMaterial
)

Serializes the shader map inline in this material, including any shader dependencies.

Public function

void

 

ReleaseShaderMap()

Releases this material's shader map.

Public function

void

 

RemoveOutstandingCompileId

(
    const int32 OldOutstandingCompileSh...
)

Public function Const

bool

 

RequiresSceneColorCopy_GameThread()

Public function Const

bool

 

RequiresSceneColorCopy_RenderThread()

Public function Virtual Const

bool

 

RequiresSynchronousCompilation()

Public function Static

void

 

RestoreEditorLoadedMaterialShadersFromMemory

(
    const TMap< FMaterialShaderMap*...
)

Recreates FShaders in editor loaded materials from the passed in memory, handling shader key changes.

Public function

void

 

SaveShaderStableKeys

(
    EShaderPlatform TargetShaderPlatfor...,
    FStableShaderKeyAndValue& SaveKeyV...
)

Public function

void

 

SerializeInlineShaderMap

(
    FArchive& Ar
)

Serializes the shader map inline in this material, including any shader dependencies.

Public function

void

 

SetCompileErrors

(
    const TArray< FString >& InCompile...
)

Public function

void

 

SetGameThreadShaderMap

(
    FMaterialShaderMap* InMaterial...
)

Public function

void

 

SetInlineShaderMap

(
    FMaterialShaderMap* InMaterial...
)

Protected function

void

 

SetQualityLevelProperties

(
    EMaterialQualityLevel::Type InQuali...,
    bool bInHasQualityLevelUsage,
    ERHIFeatureLevel::Type InFeatureLev...
)

Public function

void

 

SetRenderingThreadShaderMap

(
    FMaterialShaderMap* InMaterial...
)

Note: SetGameThreadShaderMap must also be called with the same value, but from the game thread.

Public function Virtual Const

void

 

SetupExtaCompilationSettings

(
    const EShaderPlatform Platform,
    FExtraShaderCompilerSettings& Sett...
)

Call during shader compilation jobs setup to fill additional settings that may be required by classes who inherit from this

Public function Virtual Const

bool

 

ShouldApplyFogging()

Public function Virtual Const

bool

 

ShouldBlockGI()

Public function Virtual Const

bool

 

ShouldCache

(
    EShaderPlatform Platform,
    const FShaderType* ShaderType,
    const FVertexFactoryType* Vert...
)

Should the shader for this material with the given platform, shader type and vertex factory type combination be compiled

Public function Const

bool

 

ShouldCachePipeline

(
    EShaderPlatform Platform,
    const FShaderPipelineType* Pip...,
    const FVertexFactoryType* Vert...
)

Public function Const

bool

 

ShouldCastDynamicShadows()

Returns whether this material should be considered for casting dynamic shadows.

Public function Virtual Const

bool

 

ShouldDisableDepthTest()

Public function Virtual Const

bool

 

ShouldDoContactShadows()

Public function Virtual Const

bool

 

ShouldDoSSR()

Public function Virtual Const

bool

 

ShouldEnableResponsiveAA()

Public function Virtual Const

bool

 

ShouldGenerateSphericalParticleNormals()

Public function Virtual Const

bool

 

ShouldInjectEmissiveIntoLPV()

Public function Virtual Const

bool

 

ShouldWriteOnlyAlpha()

Public function Static

void

 

UpdateEditorLoadedMaterialResources

(
    EShaderPlatform InShaderPlatform
)

Recompiles any materials in the EditorLoadedMaterialResources list if they are not complete.

Public function Virtual Const

bool

 

UseLmDirectionality()

Public function Virtual Const

bool

 

UseNormalCurvatureToRoughness()

Public function Const

bool

 

UsesCustomDepthStencil_GameThread()

Does the material use CustomDepth or CustomStencil lookup

Public function Const

bool

 

UsesEyeAdaptation()

Public function Const

bool

 

UsesGlobalDistanceField_GameThread()

Public function Const

bool

 

UsesWorldPositionOffset_GameThread()

Public function Const

bool

 

WritesEveryPixel

(
    bool bShadowPass
)

Helper function to look at both IsMasked and IsDitheredLODTransition to determine if it writes every pixel

Constants

Name

Description

EditorLoadedMaterialResources

Tracks FMaterials without a corresponding UMaterialInterface in the editor, for example FExpressionPreviews.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss