Updated Material Editor to use the available default fallback images to visually indicate a missing texture.

Material Editor also warns the user when saving a material that is populated with fallback image references.
Factored out the path strings for the default images to ImateSystemInterface.h.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
santorac
2021-11-10 19:28:42 -08:00
parent e40b226374
commit f27203a5fa
10 changed files with 113 additions and 27 deletions
@@ -12,6 +12,7 @@
#include <Atom/RPI.Edit/Material/MaterialPropertyId.h>
#include <Atom/RPI.Edit/Material/MaterialUtils.h>
#include <Atom/RPI.Public/Material/Material.h>
#include <Atom/RPI.Public/Image/ImageSystemInterface.h>
#include <Atom/RPI.Reflect/Image/Image.h>
#include <Atom/RPI.Reflect/Image/StreamingImageAsset.h>
#include <Atom/RPI.Reflect/Material/MaterialFunctor.h>
@@ -467,6 +468,37 @@ namespace MaterialEditor
{
return AzFramework::StringFunc::Path::IsExtension(m_absolutePath.c_str(), AZ::RPI::MaterialSourceData::Extension);
}
AZStd::vector<AZStd::string> MaterialDocument::GetDataWarnings() const
{
AZStd::vector<AZStd::string> warnings;
for (auto& [propertyName, dynamicProperty] : m_properties)
{
AZ::RPI::MaterialPropertyValue propertyValue = AtomToolsFramework::ConvertToRuntimeType(dynamicProperty.GetValue());
if (propertyValue.Is<AZ::Data::Asset<AZ::RPI::ImageAsset>>())
{
auto isSameAsset = [&propertyValue](const char* path)
{
AZ::Data::AssetId assetId = propertyValue.GetValue<AZ::Data::Asset<AZ::RPI::ImageAsset>>().GetId();
AZ::Data::AssetId otherAssetId;
AZ::Data::AssetCatalogRequestBus::BroadcastResult(otherAssetId, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetIdByPath, path, AZ::Data::AssetType{}, false);
return assetId == otherAssetId;
};
if (isSameAsset(AZ::RPI::DefaultImageAssetPaths::DefaultFallback) ||
isSameAsset(AZ::RPI::DefaultImageAssetPaths::Missing) ||
isSameAsset(AZ::RPI::DefaultImageAssetPaths::Processing) ||
isSameAsset(AZ::RPI::DefaultImageAssetPaths::ProcessingFailed)
)
{
warnings.push_back(AZStd::string::format("%s is using a placeholder image asset.", propertyName.GetCStr()));
}
}
}
return warnings;
}
bool MaterialDocument::CanUndo() const
{