UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MaterialSharedPrivate.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if WITH_EDITOR
6#include "Containers/Array.h"
11#include "MaterialShared.h"
16#include "RHIFeatureLevel.h"
17#include "RHIShaderPlatform.h"
18#include "SceneTypes.h"
21
22namespace UE::Cook { class FCookEventContext; }
26
28{
29
31void RecordMaterialDependenciesForCook(UE::Cook::FCookEventContext CookContext,
33
36
43{
44 FMaterialShaderMapId ShaderMapId;
45 FMaterialShaderParameters ShaderParameters;
46 EShaderPlatform ShaderPlatform;
52
53 void Save(FCbWriter& Writer) const;
54 bool TryLoad(FCbFieldView Field);
55};
56
57} // namespace UE::MaterialInterface::Private
58
59// Utility functions shared between the old and new material translator.
60namespace UE::MaterialTranslatorUtils
61{
62 // Converts a TextureAddress enum to its corresponding string representation.
64
65 // Determines the texture addressing mode for a texture based on its sampler source.
67
68 // Returns true if the LWCs are enabled in the engine.
69 bool IsLWCEnabled();
70
71 // Returns the current LWC truncation mode.
73
74 // Maps a vector transform source to a common basis (e.g., world, local, tangent).
76
77 // Maps a vector transform operation to a common basis.
79
80 // Maps a position transform source to a common basis.
82
83 // Returns true if the given float is a power of two.
84 bool IsFloatPowerOfTwo(float InValue);
85
86 // Generates HLSL defines to remap PPI_UserSceneTexture0-6 tokens generated by the HLSL emitter/translator to PPI_PostProcessInput0-6,
87 // using unoccupied slots (UsedSceneTextures bits not set) in the order they are encountered.
89
90 // Converts a scene texture identifier to its corresponding HLSL string representation.
92
93 // Returns the value type of a texture property with the specified texture value type, e.g. MCT_Float3 for Volume textures.
95
96 // Maps the specified position origin to its corresponding EWorldPositionIncludedOffsets value with an include offsets option.
98
99 // Returns a human readable name (en-US) for the specified position origin enumeration value.
101
102 // Final compile validation logic, run at the end of translation to HLSL.
107 EBlendMode BlendMode,
110 TArray<FString>& OutErrors);
111
112 // Utility function to search for the given HLSL Identifier in a block of Code. Takes into account comments and quoted text
113 // that should be ignored when searching for identifiers. Returns the start of the identifier, and the input pointer "Code"
114 // will be advanced to the first non-whitespace, non-comment character after the end of the identifier. Or null will be
115 // returned if the identifier isn't found. OutCompoundTokens contain additional tokens if it's part of a compound identifier
116 // separated by periods (for "Identifier.x", OutCompoundTokens would include "x").
118
119 // Fixup for SceneTexture and UserSceneTexture inputs to custom HLSL. See implementation for more info.
121
122 // Check for whether development feature with the given name should be enabled (currently just used for editor Selection Color).
123 bool IsDevelopmentFeatureEnabled(const FName& FeatureName, EShaderPlatform Platform, UMaterial* Material);
124
125} // namespace UE::MaterialTranslatorUtils
126
128// CompactBinary interface for FRecordedMaterialResourceForCooking
130
131inline FCbWriter& operator<<(FCbWriter& Writer,
132 const UE::MaterialInterface::Private::FRecordedMaterialResourceForCooking& Value)
133{
134 Value.Save(Writer);
135 return Writer;
136}
138 UE::MaterialInterface::Private::FRecordedMaterialResourceForCooking& OutValue);
139
141// Implementation details for UE_DEFINEINLINE_COMPACTBINARY_ENUM_INT
143
144template <typename IntType>
145inline IntType GetViewFieldAsInteger(FCbFieldView FieldView, IntType DefaultValue)
146{
147 static_assert(sizeof(IntType) != 1, "Not implemented");
148}
149template <>
151{
152 return FieldView.AsUInt8(DefaultValue);
153}
154template <>
156{
157 return FieldView.AsUInt16(DefaultValue);
158}
159
164#define UE_DEFINEINLINE_COMPACTBINARY_ENUM_INT(EnumType, IntType, NumValues, InvalidValue) \
165 inline bool LoadFromCompactBinary(FCbFieldView Field, EnumType& OutValue) \
166 { \
167 IntType IntValue = GetViewFieldAsInteger<IntType>(Field, static_cast<IntType>(InvalidValue)); \
168 if (Field.HasError() || IntValue >= static_cast<IntType>(NumValues)) \
169 { \
170 OutValue = static_cast<EnumType>(InvalidValue); \
171 return false; \
172 } \
173 OutValue = static_cast<EnumType>(IntValue); \
174 return true; \
175 } \
176 inline FCbWriter& operator<<(FCbWriter& Writer, EnumType Value) \
177 { \
178 Writer << static_cast<IntType>(Value); \
179 return Writer; \
180 }
181
183// CompactBinary functions for enums used by FRecordedMaterialResourceForCooking
185
191
192
193#endif // WITH_EDITOR
bool LoadFromCompactBinary(FCbFieldView Field, FAssetDependency &Dependency)
Definition AssetRegistry.cpp:10420
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
ESamplerSourceMode
Definition EngineTypes.h:281
EBlendMode
Definition EngineTypes.h:245
FArchive & operator<<(FArchive &Ar, FEnvQueryDebugProfileData::FStep &Data)
Definition EnvQueryTypes.cpp:489
#define X(Name, Desc)
Definition FormatStringSan.h:47
EMaterialPositionTransformSource
Definition MaterialExpressionTransformPosition.h:14
EMaterialVectorCoordTransformSource
Definition MaterialExpressionTransform.h:14
EMaterialVectorCoordTransform
Definition MaterialExpressionTransform.h:41
EWorldPositionIncludedOffsets
Definition MaterialExpressionWorldPosition.h:14
EPositionOrigin
Definition MaterialExpression.h:645
ESceneTextureId
Definition MaterialSceneTextureId.h:13
EMaterialCommonBasis
Definition MaterialShared.h:312
EMaterialValueType
Definition MaterialValueType.h:15
EShaderPlatform
Definition RHIShaderPlatform.h:11
@ SP_NumPlatforms
Definition RHIShaderPlatform.h:55
TextureAddress
Definition TextureDefines.h:496
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
Definition CompactBinary.h:610
Definition CompactBinaryWriter.h:68
Definition MaterialShared.h:806
Definition MaterialShared.h:1194
Definition NameTypes.h:617
Definition Array.h:670
Definition MaterialExpressionCustom.h:64
Definition Material.h:432
Definition Texture.h:1219
Type
Definition SceneTypes.h:132
@ Low
Definition SceneTypes.h:133
@ Num
Definition SceneTypes.h:137
Type
Definition RHIFeatureLevel.h:20
@ ES3_1
Definition RHIFeatureLevel.h:25
@ Num
Definition RHIFeatureLevel.h:54
Definition FieldSystemNoiseAlgo.cpp:6
Definition CookOnTheFly.h:19
Definition Material.cpp:823
Definition MaterialShared.h:1181
Definition EngineTypes.h:732