MaterialFunctor.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Atom/RPI.Reflect/Material/MaterialFunctor.h>
  9. #include <Atom/RPI.Reflect/Material/MaterialPropertiesLayout.h>
  10. #include <Atom/RPI.Reflect/Material/MaterialPropertyCollection.h>
  11. #include <AzCore/Serialization/SerializeContext.h>
  12. #include <Atom/RPI.Reflect/Material/ShaderCollection.h>
  13. #include <AzCore/Math/Vector2.h>
  14. #include <AzCore/Math/Vector3.h>
  15. #include <AzCore/Math/Vector4.h>
  16. #include <AzCore/Math/Color.h>
  17. namespace AZ
  18. {
  19. namespace RPI
  20. {
  21. void MaterialFunctor::Reflect(ReflectContext* context)
  22. {
  23. if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
  24. {
  25. serializeContext->Class<MaterialFunctor>()
  26. ->Version(2)
  27. ->Field("materialPropertyDependencies", &MaterialFunctor::m_materialPropertyDependencies)
  28. ;
  29. }
  30. }
  31. MaterialFunctorAPI::ConfigureShaders::ConfigureShaders(ShaderCollection* localShaderCollection)
  32. : m_localShaderCollection(localShaderCollection)
  33. {
  34. }
  35. void MaterialFunctorAPI::ConfigureShaders::ForAllShaderItems(AZStd::function<bool(ShaderCollection::Item& shaderItem)> callback)
  36. {
  37. for (ShaderCollection::Item& shaderItem : *m_localShaderCollection)
  38. {
  39. if (!callback(shaderItem))
  40. {
  41. return;
  42. }
  43. }
  44. }
  45. template<typename ValueType>
  46. bool MaterialFunctorAPI::ConfigureShaders::SetShaderOptionValueHelper(const Name& name, const ValueType& value)
  47. {
  48. bool didSetOne = false;
  49. bool materialDoesntOwnOption = false;
  50. ForAllShaderItems([&](ShaderCollection::Item& shaderItem)
  51. {
  52. ShaderOptionGroup* shaderOptionGroup = shaderItem.GetShaderOptions();
  53. const ShaderOptionGroupLayout* layout = shaderOptionGroup->GetShaderOptionLayout();
  54. ShaderOptionIndex optionIndex = layout->FindShaderOptionIndex(name);
  55. if (!optionIndex.IsValid())
  56. {
  57. return true; // skip this and continue
  58. }
  59. if (!shaderItem.MaterialOwnsShaderOption(optionIndex))
  60. {
  61. materialDoesntOwnOption = true;
  62. return false; // break;
  63. }
  64. if (shaderOptionGroup->SetValue(optionIndex, value))
  65. {
  66. didSetOne = true;
  67. }
  68. return true; // continue
  69. });
  70. if (materialDoesntOwnOption)
  71. {
  72. AZ_Error("MaterialFunctor", false, "Shader option '%s' is not owned by this material.", name.GetCStr());
  73. AZ_Assert(!didSetOne, "The material build pipeline should have ensured that MaterialOwnsShaderOption is consistent across all shaders.");
  74. }
  75. else if (!didSetOne)
  76. {
  77. AZ_Error("MaterialFunctor", false, "Shader option '%s' not found.", name.GetCStr());
  78. }
  79. return didSetOne;
  80. }
  81. bool MaterialFunctorAPI::ConfigureShaders::SetShaderOptionValue(const Name& optionName, ShaderOptionValue value)
  82. {
  83. return SetShaderOptionValueHelper(optionName, value);
  84. }
  85. bool MaterialFunctorAPI::ConfigureShaders::SetShaderOptionValue(const Name& optionName, const Name& value)
  86. {
  87. return SetShaderOptionValueHelper(optionName, value);
  88. }
  89. AZStd::size_t MaterialFunctorAPI::ConfigureShaders::GetShaderCount() const
  90. {
  91. return m_localShaderCollection->size();
  92. }
  93. void MaterialFunctorAPI::ConfigureShaders::SetShaderEnabled(AZStd::size_t shaderIndex, bool enabled)
  94. {
  95. (*m_localShaderCollection)[shaderIndex].SetEnabled(enabled);
  96. }
  97. void MaterialFunctorAPI::ConfigureShaders::SetShaderEnabled(const AZ::Name& shaderTag, bool enabled)
  98. {
  99. (*m_localShaderCollection)[shaderTag].SetEnabled(enabled);
  100. }
  101. void MaterialFunctorAPI::ConfigureShaders::SetShaderDrawListTagOverride(AZStd::size_t shaderIndex, const Name& drawListTagName)
  102. {
  103. (*m_localShaderCollection)[shaderIndex].SetDrawListTagOverride(drawListTagName);
  104. }
  105. void MaterialFunctorAPI::ConfigureShaders::SetShaderDrawListTagOverride(const AZ::Name& shaderTag, const Name& drawListTagName)
  106. {
  107. (*m_localShaderCollection)[shaderTag].SetDrawListTagOverride(drawListTagName);
  108. }
  109. void MaterialFunctorAPI::ConfigureShaders::ApplyShaderRenderStateOverlay(AZStd::size_t shaderIndex, const RHI::RenderStates& renderStatesOverlay)
  110. {
  111. RHI::MergeStateInto(renderStatesOverlay, *((*m_localShaderCollection)[shaderIndex].GetRenderStatesOverlay()));
  112. }
  113. void MaterialFunctorAPI::ConfigureShaders::ApplyShaderRenderStateOverlay(const AZ::Name& shaderTag, const RHI::RenderStates& renderStatesOverlay)
  114. {
  115. RHI::MergeStateInto(renderStatesOverlay, *((*m_localShaderCollection)[shaderTag].GetRenderStatesOverlay()));
  116. }
  117. MaterialFunctorAPI::RuntimeContext::RuntimeContext(
  118. const MaterialPropertyCollection& materialProperties,
  119. const MaterialPropertyFlags* materialPropertyDependencies,
  120. MaterialPropertyPsoHandling psoHandling,
  121. ShaderResourceGroup* shaderResourceGroup,
  122. ShaderCollection* generalShaderCollection,
  123. MaterialPipelineDataMap* materialPipelineData
  124. )
  125. : MaterialFunctorAPI::CommonRuntimeConfiguration(psoHandling)
  126. , MaterialFunctorAPI::ReadMaterialPropertyValues(materialProperties, materialPropertyDependencies)
  127. , MaterialFunctorAPI::ConfigureShaders(generalShaderCollection)
  128. , m_shaderResourceGroup(shaderResourceGroup)
  129. , m_materialPipelineData(materialPipelineData)
  130. {
  131. }
  132. void MaterialFunctorAPI::RuntimeContext::ForAllShaderItems(AZStd::function<bool(ShaderCollection::Item& shaderItem)> callback)
  133. {
  134. MaterialFunctorAPI::ConfigureShaders::ForAllShaderItems(callback);
  135. for (auto& materialPipelinePair : *m_materialPipelineData)
  136. {
  137. for (ShaderCollection::Item& shaderItem : materialPipelinePair.second.m_shaderCollection)
  138. {
  139. if (!callback(shaderItem))
  140. {
  141. return;
  142. }
  143. }
  144. }
  145. }
  146. ShaderResourceGroup* MaterialFunctorAPI::RuntimeContext::GetShaderResourceGroup()
  147. {
  148. return m_shaderResourceGroup;
  149. }
  150. bool MaterialFunctorAPI::RuntimeContext::SetInternalMaterialPropertyValue(const Name& propertyId, const MaterialPropertyValue& value)
  151. {
  152. bool somethingWasSet = false;
  153. for (auto& materialPipelinePair : *m_materialPipelineData)
  154. {
  155. MaterialPropertyCollection& properties = materialPipelinePair.second.m_materialProperties;
  156. MaterialPropertyIndex index = properties.GetMaterialPropertiesLayout()->FindPropertyIndex(propertyId);
  157. if (!index.IsValid())
  158. {
  159. continue;
  160. }
  161. if (properties.SetPropertyValue(index, value))
  162. {
  163. somethingWasSet = true;
  164. }
  165. }
  166. return somethingWasSet;
  167. }
  168. MaterialFunctorAPI::PipelineRuntimeContext::PipelineRuntimeContext(
  169. const MaterialPropertyCollection& internalProperties,
  170. const MaterialPropertyFlags* internalMaterialPropertyDependencies,
  171. MaterialPropertyPsoHandling psoHandling,
  172. ShaderCollection* pipelineShaderCollections
  173. )
  174. : MaterialFunctorAPI::CommonRuntimeConfiguration(psoHandling)
  175. , MaterialFunctorAPI::ReadMaterialPropertyValues(internalProperties, internalMaterialPropertyDependencies)
  176. , MaterialFunctorAPI::ConfigureShaders(pipelineShaderCollections)
  177. {
  178. }
  179. MaterialFunctorAPI::EditorContext::EditorContext(
  180. const MaterialPropertyCollection& materialProperties,
  181. AZStd::unordered_map<Name, MaterialPropertyDynamicMetadata>& propertyMetadata,
  182. AZStd::unordered_map<Name, MaterialPropertyGroupDynamicMetadata>& propertyGroupMetadata,
  183. AZStd::unordered_set<Name>& updatedPropertiesOut,
  184. AZStd::unordered_set<Name>& updatedPropertyGroupsOut,
  185. const MaterialPropertyFlags* materialPropertyDependencies
  186. )
  187. : MaterialFunctorAPI::ReadMaterialPropertyValues(materialProperties, materialPropertyDependencies)
  188. , m_propertyMetadata(propertyMetadata)
  189. , m_propertyGroupMetadata(propertyGroupMetadata)
  190. , m_updatedPropertiesOut(updatedPropertiesOut)
  191. , m_updatedPropertyGroupsOut(updatedPropertyGroupsOut)
  192. {}
  193. const MaterialPropertyDynamicMetadata* MaterialFunctorAPI::EditorContext::GetMaterialPropertyMetadata(const Name& propertyId) const
  194. {
  195. return QueryMaterialPropertyMetadata(propertyId);
  196. }
  197. const MaterialPropertyDynamicMetadata* MaterialFunctorAPI::EditorContext::GetMaterialPropertyMetadata(const MaterialPropertyIndex& index) const
  198. {
  199. const Name& name = m_materialProperties.GetMaterialPropertiesLayout()->GetPropertyDescriptor(index)->GetName();
  200. return GetMaterialPropertyMetadata(name);
  201. }
  202. const MaterialPropertyGroupDynamicMetadata* MaterialFunctorAPI::EditorContext::GetMaterialPropertyGroupMetadata(const Name& propertyId) const
  203. {
  204. return QueryMaterialPropertyGroupMetadata(propertyId);
  205. }
  206. bool MaterialFunctorAPI::EditorContext::SetMaterialPropertyGroupVisibility(const Name& propertyGroupName, MaterialPropertyGroupVisibility visibility)
  207. {
  208. MaterialPropertyGroupDynamicMetadata* metadata = QueryMaterialPropertyGroupMetadata(propertyGroupName);
  209. if (!metadata)
  210. {
  211. return false;
  212. }
  213. if (metadata->m_visibility != visibility)
  214. {
  215. metadata->m_visibility = visibility;
  216. m_updatedPropertyGroupsOut.insert(propertyGroupName);
  217. }
  218. return true;
  219. }
  220. bool MaterialFunctorAPI::EditorContext::SetMaterialPropertyVisibility(const Name& propertyId, MaterialPropertyVisibility visibility)
  221. {
  222. MaterialPropertyDynamicMetadata* metadata = QueryMaterialPropertyMetadata(propertyId);
  223. if (!metadata)
  224. {
  225. return false;
  226. }
  227. if (metadata->m_visibility != visibility)
  228. {
  229. metadata->m_visibility = visibility;
  230. m_updatedPropertiesOut.insert(propertyId);
  231. }
  232. return true;
  233. }
  234. bool MaterialFunctorAPI::EditorContext::SetMaterialPropertyVisibility(const MaterialPropertyIndex& index, MaterialPropertyVisibility visibility)
  235. {
  236. const Name& name = m_materialProperties.GetMaterialPropertiesLayout()->GetPropertyDescriptor(index)->GetName();
  237. return SetMaterialPropertyVisibility(name, visibility);
  238. }
  239. bool MaterialFunctorAPI::EditorContext::SetMaterialPropertyDescription(const Name& propertyId, AZStd::string description)
  240. {
  241. MaterialPropertyDynamicMetadata* metadata = QueryMaterialPropertyMetadata(propertyId);
  242. if (!metadata)
  243. {
  244. return false;
  245. }
  246. if (metadata->m_description != description)
  247. {
  248. metadata->m_description = description;
  249. m_updatedPropertiesOut.insert(propertyId);
  250. }
  251. return true;
  252. }
  253. bool MaterialFunctorAPI::EditorContext::SetMaterialPropertyDescription(const MaterialPropertyIndex& index, AZStd::string description)
  254. {
  255. const Name& name = m_materialProperties.GetMaterialPropertiesLayout()->GetPropertyDescriptor(index)->GetName();
  256. return SetMaterialPropertyDescription(name, description);
  257. }
  258. bool MaterialFunctorAPI::EditorContext::SetMaterialPropertyMinValue(const Name& propertyId, const MaterialPropertyValue& min)
  259. {
  260. MaterialPropertyDynamicMetadata* metadata = QueryMaterialPropertyMetadata(propertyId);
  261. if (!metadata)
  262. {
  263. return false;
  264. }
  265. if(metadata->m_propertyRange.m_min != min)
  266. {
  267. metadata->m_propertyRange.m_min = min;
  268. m_updatedPropertiesOut.insert(propertyId);
  269. }
  270. return true;
  271. }
  272. bool MaterialFunctorAPI::EditorContext::SetMaterialPropertyMinValue(const MaterialPropertyIndex& index, const MaterialPropertyValue& min)
  273. {
  274. const Name& name = m_materialProperties.GetMaterialPropertiesLayout()->GetPropertyDescriptor(index)->GetName();
  275. return SetMaterialPropertyMinValue(name, min);
  276. }
  277. bool MaterialFunctorAPI::EditorContext::SetMaterialPropertyMaxValue(const Name& propertyId, const MaterialPropertyValue& max)
  278. {
  279. MaterialPropertyDynamicMetadata* metadata = QueryMaterialPropertyMetadata(propertyId);
  280. if (!metadata)
  281. {
  282. return false;
  283. }
  284. if (metadata->m_propertyRange.m_max != max)
  285. {
  286. metadata->m_propertyRange.m_max = max;
  287. m_updatedPropertiesOut.insert(propertyId);
  288. }
  289. return true;
  290. }
  291. bool MaterialFunctorAPI::EditorContext::SetMaterialPropertyMaxValue(const MaterialPropertyIndex& index, const MaterialPropertyValue& max)
  292. {
  293. const Name& name = m_materialProperties.GetMaterialPropertiesLayout()->GetPropertyDescriptor(index)->GetName();
  294. return SetMaterialPropertyMaxValue(name, max);
  295. }
  296. bool MaterialFunctorAPI::EditorContext::SetMaterialPropertySoftMinValue(const Name& propertyId, const MaterialPropertyValue& min)
  297. {
  298. MaterialPropertyDynamicMetadata* metadata = QueryMaterialPropertyMetadata(propertyId);
  299. if (!metadata)
  300. {
  301. return false;
  302. }
  303. if (metadata->m_propertyRange.m_softMin != min)
  304. {
  305. metadata->m_propertyRange.m_softMin = min;
  306. m_updatedPropertiesOut.insert(propertyId);
  307. }
  308. return true;
  309. }
  310. bool MaterialFunctorAPI::EditorContext::SetMaterialPropertySoftMinValue(const MaterialPropertyIndex& index, const MaterialPropertyValue& min)
  311. {
  312. const Name& name = m_materialProperties.GetMaterialPropertiesLayout()->GetPropertyDescriptor(index)->GetName();
  313. return SetMaterialPropertySoftMinValue(name, min);
  314. }
  315. bool MaterialFunctorAPI::EditorContext::SetMaterialPropertySoftMaxValue(const Name& propertyId, const MaterialPropertyValue& max)
  316. {
  317. MaterialPropertyDynamicMetadata* metadata = QueryMaterialPropertyMetadata(propertyId);
  318. if (!metadata)
  319. {
  320. return false;
  321. }
  322. if (metadata->m_propertyRange.m_softMax != max)
  323. {
  324. metadata->m_propertyRange.m_softMax = max;
  325. m_updatedPropertiesOut.insert(propertyId);
  326. }
  327. return true;
  328. }
  329. bool MaterialFunctorAPI::EditorContext::SetMaterialPropertySoftMaxValue(const MaterialPropertyIndex& index, const MaterialPropertyValue& max)
  330. {
  331. const Name& name = m_materialProperties.GetMaterialPropertiesLayout()->GetPropertyDescriptor(index)->GetName();
  332. return SetMaterialPropertySoftMaxValue(name, max);
  333. }
  334. MaterialPropertyDynamicMetadata* MaterialFunctorAPI::EditorContext::QueryMaterialPropertyMetadata(const Name& propertyId) const
  335. {
  336. auto it = m_propertyMetadata.find(propertyId);
  337. if (it == m_propertyMetadata.end())
  338. {
  339. AZ_Error("MaterialFunctor", false, "Couldn't find metadata for material property: %s.", propertyId.GetCStr());
  340. return nullptr;
  341. }
  342. return &it->second;
  343. }
  344. MaterialPropertyGroupDynamicMetadata* MaterialFunctorAPI::EditorContext::QueryMaterialPropertyGroupMetadata(const Name& propertyGroupId) const
  345. {
  346. auto it = m_propertyGroupMetadata.find(propertyGroupId);
  347. if (it == m_propertyGroupMetadata.end())
  348. {
  349. AZ_Error("MaterialFunctor", false, "Couldn't find metadata for material property group: %s.", propertyGroupId.GetCStr());
  350. return nullptr;
  351. }
  352. return &it->second;
  353. }
  354. MaterialFunctorAPI::ReadMaterialPropertyValues::ReadMaterialPropertyValues(
  355. const MaterialPropertyCollection& materialProperties,
  356. const MaterialPropertyFlags* materialPropertyDependencies
  357. )
  358. : m_materialProperties(materialProperties)
  359. , m_materialPropertyDependencies(materialPropertyDependencies)
  360. { }
  361. template<typename Type>
  362. const Type& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue(const MaterialPropertyIndex& index) const
  363. {
  364. return GetMaterialPropertyValue(index).GetValue<Type>();
  365. }
  366. // explicit template instantiation
  367. template AZ_DLL_EXPORT const bool& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<bool> (const Name& propertyId) const;
  368. template AZ_DLL_EXPORT const int32_t& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<int32_t> (const Name& propertyId) const;
  369. template AZ_DLL_EXPORT const uint32_t& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<uint32_t> (const Name& propertyId) const;
  370. template AZ_DLL_EXPORT const float& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<float> (const Name& propertyId) const;
  371. template AZ_DLL_EXPORT const Vector2& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<Vector2> (const Name& propertyId) const;
  372. template AZ_DLL_EXPORT const Vector3& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<Vector3> (const Name& propertyId) const;
  373. template AZ_DLL_EXPORT const Vector4& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<Vector4> (const Name& propertyId) const;
  374. template AZ_DLL_EXPORT const Color& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<Color> (const Name& propertyId) const;
  375. template AZ_DLL_EXPORT const Data::Instance<Image>& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<Data::Instance<Image>>(const Name& propertyId) const;
  376. template<typename Type>
  377. const Type& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue(const Name& propertyId) const
  378. {
  379. return GetMaterialPropertyValue(propertyId).GetValue<Type>();
  380. }
  381. // explicit template instantiation
  382. template AZ_DLL_EXPORT const bool& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<bool> (const MaterialPropertyIndex& index) const;
  383. template AZ_DLL_EXPORT const int32_t& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<int32_t> (const MaterialPropertyIndex& index) const;
  384. template AZ_DLL_EXPORT const uint32_t& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<uint32_t> (const MaterialPropertyIndex& index) const;
  385. template AZ_DLL_EXPORT const float& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<float> (const MaterialPropertyIndex& index) const;
  386. template AZ_DLL_EXPORT const Vector2& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<Vector2> (const MaterialPropertyIndex& index) const;
  387. template AZ_DLL_EXPORT const Vector3& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<Vector3> (const MaterialPropertyIndex& index) const;
  388. template AZ_DLL_EXPORT const Vector4& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<Vector4> (const MaterialPropertyIndex& index) const;
  389. template AZ_DLL_EXPORT const Color& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<Color> (const MaterialPropertyIndex& index) const;
  390. template AZ_DLL_EXPORT const Data::Instance<Image>& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue<Data::Instance<Image>> (const MaterialPropertyIndex& index) const;
  391. void CheckPropertyAccess([[maybe_unused]] const MaterialPropertyIndex& index, [[maybe_unused]] const MaterialPropertyFlags& materialPropertyDependencies, [[maybe_unused]] const MaterialPropertiesLayout& materialPropertiesLayout)
  392. {
  393. #if defined(AZ_ENABLE_TRACING)
  394. if (!materialPropertyDependencies.test(index.GetIndex()))
  395. {
  396. const MaterialPropertyDescriptor* propertyDescriptor = materialPropertiesLayout.GetPropertyDescriptor(index);
  397. AZ_Error("MaterialFunctor", false, "Material functor accessing an unregistered material property '%s'.",
  398. propertyDescriptor ? propertyDescriptor->GetName().GetCStr() : "<unknown>");
  399. }
  400. #endif
  401. }
  402. const MaterialPropertiesLayout* MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertiesLayout() const
  403. {
  404. return m_materialProperties.GetMaterialPropertiesLayout().get();
  405. }
  406. const MaterialPropertyValue& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue(const MaterialPropertyIndex& index) const
  407. {
  408. CheckPropertyAccess(index, *m_materialPropertyDependencies, *GetMaterialPropertiesLayout());
  409. return m_materialProperties.GetPropertyValue(index);
  410. }
  411. const MaterialPropertyValue& MaterialFunctorAPI::ReadMaterialPropertyValues::GetMaterialPropertyValue(const Name& propertyId) const
  412. {
  413. MaterialPropertyIndex index = GetMaterialPropertiesLayout()->FindPropertyIndex(propertyId);
  414. return GetMaterialPropertyValue(index);
  415. }
  416. bool MaterialFunctor::NeedsProcess(const MaterialPropertyFlags& propertyDirtyFlags)
  417. {
  418. return (m_materialPropertyDependencies & propertyDirtyFlags).any();
  419. }
  420. const MaterialPropertyFlags& MaterialFunctor::GetMaterialPropertyDependencies() const
  421. {
  422. return m_materialPropertyDependencies;
  423. }
  424. } // namespace RPI
  425. } // namespace AZ