Navigation
API > API/Runtime > API/Runtime/Engine
Inheritance Hierarchy
- FMaterial
- FMaterialResource
- FMaterialResourceStats
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
| Type | Name | Description | |
|---|---|---|---|
| FUniformParameterOverrides | TransientOverrides |
Constructors
| Type | Name | Description | |
|---|---|---|---|
FMaterial () |
Minimal initialization constructor. |
Destructors
| Type | Name | Description | |
|---|---|---|---|
~FMaterial () |
Destructor |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | AddEditorLoadedMaterialResource
(
FMaterial* Material |
Adds an FMaterial to the global list. | |
| uint32 | AddRef () |
||
| void | AddReferencedObjects
(
FReferenceCollector& Collector |
||
| bool | |||
| void | BackupEditorLoadedMaterialShadersToMemory
(
TMap< FMaterialShaderMap*, TUniquePtr< TArray< uint8 > > >& ShaderMapToSerializedShaderData |
Backs up any FShaders in editor loaded materials to memory through serialization and clears FShader references. | |
| void | |||
| void | BeginCacheShaders
(
const FMaterialShaderMapId& ShaderMapId, |
Begins caching the material shaders for the given static parameter set and platform. | |
| void | BeginCacheShaders
(
EShaderPlatform Platform, |
Begins caching the material shaders for the given static parameter set and platform. | |
| void | CacheGivenTypes
(
EShaderPlatform ShaderPlatform, |
Submits local compile jobs for the exact given shader types and vertex factory type combination. | |
| bool | CacheShaders
(
const FMaterialShaderMapId& ShaderMapId, |
Caches the material shaders for the given static parameter set and platform. | |
| bool | CacheShaders
(
EShaderPlatform Platform, |
Caches the material shaders for this material on the given platform. | |
| void | Cancels all outstanding compilation jobs for this material. | ||
| bool | |||
| bool | CheckInValidStateForCompilation
(
FMaterialCompiler* Compiler |
Checks that no pre-compilation errors have been detected and if so it reports them using specified compiler. | |
| FGraphEventArray | CollectPSOs
(
ERHIFeatureLevel::Type InFeatureLevel, |
Collect all possible PSO's which can be used with this material for given parameters - PSOs will be async precached | |
| int32 | CompilePropertyAndSetMaterialProperty
(
EMaterialProperty Property, |
Entry point for compiling a specific material property. This must call SetMaterialProperty. | |
| bool | |||
| void | DeferredDelete
(
FMaterial* Material |
||
| void | DeferredDeleteArray
(
TArray< TMaterial* >& Materials |
||
| void | DeferredDeleteArray
(
TArray< TRefCountPtr< TMaterial >>& Materials |
||
| void | DeleteMaterialsOnRenderThread
(
TArray< TRefCountPtr< FMaterial >>& MaterialsRenderThread |
||
| void | Discards loaded shader maps if the application can't render | ||
| void | DumpDebugInfo
(
FOutputDevice& OutputDevice |
||
| void | |||
| bool | Finishes any pending material caching. | ||
| void | Blocks until compilation has completed. Returns immediately if a compilation is not outstanding. | ||
| void | GatherCustomOutputExpressions
(
TArray< class UMaterialExpressionCustomOutput* >& OutCustomOutputs |
Gather any UMaterialExpressionCustomOutput expressions they can be compiled in turn | |
| void | GatherExpressionsForCustomInterpolators
(
TArray< class UMaterialExpression* >& OutExpressions |
Gather any UMaterialExpressionCustomOutput expressions in the material and referenced function calls | |
| bool | Returns true if this material is allowed to make development shaders via the global CVar CompileShadersForDevelopment. | ||
| FString | GetAssetName () |
Similar to GetFriendlyName, but but avoids historical behavior of the former, returning the exact asset name for material instances instead of just the material. | |
| FName | GetAssetPath () |
Allows to associate the shader resources with the asset for load order. | |
| FString | Useful for debugging. | ||
| int32 | |||
| bool | |||
| enum EBlendMode | GetBlendMode () |
||
| const FMaterialCachedExpressionData & | |||
| const FMaterialCachedHLSLTree * | |||
| bool | |||
| const TArray< FString > & | |||
| uint8 | The material usage mask of CustomDepth and CustomStencil | ||
| FString | GetDebugName () |
||
| void | GetDependentShaderAndVFTypes
(
EShaderPlatform Platform, |
Produces arrays of any shader and vertex factory type that this material is dependent on. | |
| FDisplacementScaling | |||
| const TArray< UMaterialExpression * > & | |||
| const FStaticFeatureLevel | |||
| bool | |||
| FString | |||
| FString | GetFullPath () |
||
| uint32 | |||
| FMaterialShaderMap * | |||
| const FGuid & | GetLegacyId () |
||
| bool | |||
| uint32 | |||
| EMaterialDomain | |||
| 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 | |
| enum EMaterialFloatPrecisionMode | |||
| UMaterialExpression * | The returned value is not const because the expression is used to build the Strata tree and this requires to execute multiple such as link function caller, compile expression, etc. | ||
| FGuid | Gets the Guid that represents this material. | ||
| UMaterialInterface * | |||
| EMaterialShaderMapUsage::Type | Returns which shadermap this material is bound to. | ||
| FString | Returns a string that describes the material's usage for debugging purposes. | ||
| int32 | |||
| float | |||
| FName | For tracking ownership data | ||
| EMaterialQualityLevel::Type | |||
| uint32 | GetRefCount () |
||
| TArrayView< const TObjectPtr< UObject > > | |||
| ERefractionCoverageMode | |||
| float | |||
| enum ERefractionMode | |||
| FMaterialShaderMap * | |||
| bool | |||
| uint8 | Get the runtime virtual texture output attribute mask for the material. | ||
| uint8 | |||
| TShaderRef< ShaderType > | GetShader
(
FVertexFactoryType* VertexFactoryType, |
Finds the shader matching the template type and the passed in vertex factory, asserts if not found. | |
| TShaderRef< ShaderType > | GetShader
(
FVertexFactoryType* VertexFactoryType, |
||
| void | GetShaderMapId
(
EShaderPlatform Platform, |
Material properties. | |
| void | GetShaderMapIDsWithUnfinishedCompilation
(
TArray< int32 >& ShaderMapIds |
Fills the passed array with IDs of shader maps unfinished compilation jobs. | |
| const FMaterialShaderMap * | Shared code needed for GetUniformScalarParameterExpressions, GetUniformVectorParameterExpressions, GetUniformCubeTextureExpressions.. | ||
| EMaterialShaderMapUsage::Type | Gets the shader map usage of the material, which will be included in the DDC key. | ||
| FShaderPipelineRef | GetShaderPipeline
(
FShaderPipelineType* ShaderPipelineType, |
||
| void | GetShaderTypes
(
EShaderPlatform Platform, |
Gathers a list of shader types sorted by vertex factory types that should be cached for this material. | |
| void | GetShaderTypesForLayout
(
EShaderPlatform Platform, |
||
| FMaterialShadingModelField | |||
| EMaterialShadingRate | |||
| void | GetStaticParameterSet
(
EShaderPlatform Platform, |
||
| uint32 | |||
| uint32 | |||
| const FStrataCompilationConfig & | Get to the strata compilation config | ||
| float | |||
| enum ETranslucencyLightingMode | |||
| float | |||
| FLinearColor | |||
| float | |||
| float | |||
| float | |||
| float | |||
| float | |||
| TArrayView< const FMaterialTextureParameterInfo > | |||
| TArrayView< const FMaterialTextureParameterInfo > | |||
| TArrayView< const FMaterialTextureParameterInfo > | |||
| const FUniformExpressionSet & | Accessors. | ||
| TArrayView< const FMaterialNumericParameterInfo > | |||
| TArrayView< const FMaterialTextureParameterInfo > | |||
| TArrayView< const FMaterialTextureParameterInfo > | GetUniformTextureExpressions
(
EMaterialTextureParameterType Type |
||
| TArrayView< const FMaterialTextureParameterInfo > | |||
| TArrayView< const FMaterialTextureParameterInfo > | |||
| FString | GetUniqueAssetName
(
EShaderPlatform Platform, |
Similar to GetFriendlyName, but appends a hash of shader map ID portion of the DDC key (excluding source file hashes) to differentiate materials/material instances that would collide when considering the base material name alone (this name is used when creating debug output paths for disambiguation). | |
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | HasMaterialPropertyConnected
(
EMaterialProperty In |
||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | HasShaders
(
const FMaterialShaderTypes& InTypes, |
||
| bool | |||
| bool | Checks if there is a valid GameThreadShaderMap, that is, the material can be rendered as intended. | ||
| bool | |||
| bool | |||
| bool | Returns whether or not a material caching is still pending. | ||
| bool | Checks if the compilation for this shader is finished | ||
| bool | |||
| bool | |||
| bool | IsDistorted () |
||
| bool | |||
| bool | |||
| bool | IsDualBlendingEnabled
(
EShaderPlatform Platform |
||
| bool | IsFullyRough () |
||
| bool | |||
| bool | |||
| bool | IsMasked () |
||
| bool | |||
| bool | |||
| bool | IsNonmetal () |
||
| bool | |||
| bool | IsPersistent () |
Should shaders compiled for this material be saved to disk? | |
| bool | |||
| bool | IsPreview () |
||
| bool | |||
| bool | Is the material required to be complete? Default materials, special engine materials, etc | ||
| bool | |||
| bool | IsSky () |
||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | IsTwoSided () |
||
| bool | IsUIMaterial () |
||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | IsUsedWithUI () |
||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | Should the material be compiled using exec pin? | ||
| bool | |||
| bool | Is the material using the new (WIP) HLSL generator? | ||
| bool | |||
| bool | |||
| bool | |||
| bool | IsWireframe () |
||
| void | LegacySerialize
(
FArchive& Ar |
Serializes the material. | |
| uint8 | Get Strata material BSDF count. | ||
| uint8 | |||
| uint8 | Get Strata material type (single, single, complex slab). | ||
| uint8 | |||
| uint8 | Get Strata material uint count per pixel. | ||
| uint8 | |||
| bool | Get Strata material special path requirement (for more expenssive features such as Glints or SpecularLUT). | ||
| bool | |||
| bool | Note: This function is only intended for use in deciding whether or not shader permutations are required before material translation occurs. | ||
| bool | |||
| bool | Does the material modify the mesh position. | ||
| bool | |||
| bool | |||
| bool | |||
| bool | Does the material use displacement. | ||
| bool | Does the material use a distance cull fade. | ||
| bool | |||
| bool | Does the material use a pixel depth offset. | ||
| bool | |||
| bool | Does the material use a SceneDepth lookup. | ||
| bool | |||
| bool | Does the material use world position offset. | ||
| bool | NeedsGBuffer () |
||
| bool | |||
| void | Called when compilation of an FMaterial finishes, after the GameThreadShaderMap is set and the render command to set the RenderThreadShaderMap is queued | ||
| bool | Prepares to destroy the material, must be called from game thread Returns 'true' if PrepareDestroy_RenderThread() is required | ||
| void | Prepares to destroy the material, must be called from render thread, only if PrepareDestroy_GameThread() returned true | ||
| void | RegisterInlineShaderMap
(
bool bLoadedByCookedMaterial |
Serializes the shader map inline in this material, including any shader dependencies. | |
| uint32 | Release () |
||
| void | Releases this material's shader map. | ||
| bool | |||
| bool | |||
| bool | |||
| void | RestoreEditorLoadedMaterialShadersFromMemory
(
const TMap< FMaterialShaderMap*, TUniquePtr< TArray< uint8 > > >& ShaderMapToSerializedShaderD... |
Recreates FShaders in editor loaded materials from the passed in memory, handling shader key changes. | |
| void | SaveShaderStableKeys
(
EShaderPlatform TargetShaderPlatform, |
||
| void | SerializeInlineShaderMap
(
FArchive& Ar |
Serializes the shader map inline in this material, including any shader dependencies. | |
| void | SetCompileErrors
(
const TArray< FString >& InCompileErrors |
||
| void | SetCompilingShaderMap
(
FMaterialShaderMap* InMaterialShaderMap |
||
| void | SetGameThreadShaderMap
(
FMaterialShaderMap* InMaterialShaderMap |
||
| void | SetInlineShaderMap
(
FMaterialShaderMap* InMaterialShaderMap |
||
| void | |||
| void | SetQualityLevelProperties
(
ERHIFeatureLevel::Type InFeatureLevel, |
||
| void | SetRenderingThreadShaderMap
(
TRefCountPtr< FMaterialShaderMap >& InMaterialShaderMap |
||
| void | SetShaderMapsOnMaterialResources
(
const TMap< TRefCountPtr< FMaterial >, TRefCountPtr< FMaterialShaderMap >>& MaterialsToUpdate |
Sets shader maps on the specified materials without blocking. | |
| void | SetStrataCompilationConfig
(
FStrataCompilationConfig& StrataCompilationConfig |
Set the strata compilation config | |
| void | SetupExtraCompilationSettings
(
const EShaderPlatform Platform, |
Call during shader compilation jobs setup to fill additional settings that may be required by classes who inherit from this | |
| bool | |||
| bool | |||
| bool | |||
| bool | ShouldCache
(
EShaderPlatform Platform, |
Should the shader for this material with the given platform, shader type and vertex factory type combination be compiled | |
| bool | ShouldCachePipeline
(
EShaderPlatform Platform, |
||
| bool | ShouldCacheShaders
(
const EShaderPlatform ShaderPlatform, |
||
| bool | Returns whether this material should be considered for casting dynamic shadows. | ||
| bool | |||
| bool | |||
| bool | ShouldDoSSR () |
||
| bool | |||
| bool | |||
| bool | Some materials may be loaded early - before the shader library - and need their code inlined | ||
| bool | |||
| void | SubmitCompileJobs_GameThread
(
EShaderCompileJobPriority Priority |
||
| void | SubmitCompileJobs_RenderThread
(
EShaderCompileJobPriority Priority |
||
| bool | TryGetShaders
(
const FMaterialShaderTypes& InTypes, |
||
| void | UpdateEditorLoadedMaterialResources
(
EShaderPlatform InShaderPlatform |
Recompiles any materials in the EditorLoadedMaterialResources list if they are not complete. | |
| void | |||
| bool | |||
| bool | |||
| bool | |||
| bool | |||
| bool | WritesEveryPixel
(
bool bShadowPass |
Helper function to look at both IsMasked and IsDitheredLODTransition to determine if it writes every pixel | |
| 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. |
| PrecachedPSORequestIDsCS | Shared critical section on PrecachedPSORequestIDs because contention should be very limited |
Deprecated Functions
| Type | Name | Description | |
|---|---|---|---|
| bool | Should instead check individual properties | ||
| bool | This function is deprecated. Use MaterialUsesPixelDepthOffset_RenderThread() instead. | ||
| void | SetQualityLevelProperties
(
EMaterialQualityLevel::Type InQualityLevel, |
Parameter bInHasQualityLevelUsage is deprecated | |
| bool | This function is deprecated. Use MaterialUsesWorldPositionOffset_GameThread() instead. |