Use a different fallback image depending on the status of the asset. Including a setting to use a friendly image that is less obnoxious for anything that might have been missed in a release build
Signed-off-by: Tommy Walton <waltont@amazon.com>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <Atom/RPI.Reflect/Image/StreamingImageAssetHandler.h>
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
#include <AzFramework/Asset/AssetSystemBus.h>
|
||||
|
||||
namespace AZ
|
||||
@@ -44,30 +45,58 @@ namespace AZ
|
||||
|
||||
Data::AssetId StreamingImageAssetHandler::AssetMissingInCatalog(const Data::Asset<Data::AssetData>& asset)
|
||||
{
|
||||
// Escalate the asset to the top of the list
|
||||
AzFramework::AssetSystemRequestBus::Broadcast(
|
||||
&AzFramework::AssetSystem::AssetSystemRequests::EscalateAssetByUuid, asset.GetId().m_guid);
|
||||
// Find out if the asset is missing completely, or just still processing
|
||||
// and escalate the asset to the top of the list
|
||||
AzFramework::AssetSystem::AssetStatus missingAssetStatus;
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
missingAssetStatus, &AzFramework::AssetSystem::AssetSystemRequests::GetAssetStatusById, asset.GetId().m_guid);
|
||||
|
||||
// Make sure the default fallback image has been processed so that it is part of the asset catalog
|
||||
// Generate asset info to use to register the fallback asset with the asset catalog
|
||||
Data::AssetInfo assetInfo;
|
||||
assetInfo.m_relativePath = "textures/defaults/defaultfallback.png.streamingimage";
|
||||
assetInfo.m_assetType = azrtti_typeid<StreamingImageAsset>();
|
||||
|
||||
bool useDebugFallbackImages = true;
|
||||
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
|
||||
{
|
||||
settingsRegistry->GetObject(useDebugFallbackImages, "/O3DE/Atom/RPI/UseDebugFallbackImages");
|
||||
}
|
||||
|
||||
if (useDebugFallbackImages)
|
||||
{
|
||||
switch (missingAssetStatus)
|
||||
{
|
||||
case AzFramework::AssetSystem::AssetStatus::AssetStatus_Queued:
|
||||
case AzFramework::AssetSystem::AssetStatus::AssetStatus_Compiling:
|
||||
assetInfo.m_relativePath = "textures/defaults/processing.png.streamingimage";
|
||||
break;
|
||||
case AzFramework::AssetSystem::AssetStatus::AssetStatus_Failed:
|
||||
assetInfo.m_relativePath = "textures/defaults/processingfailed.png.streamingimage";
|
||||
break;
|
||||
case AzFramework::AssetSystem::AssetStatus::AssetStatus_Missing:
|
||||
case AzFramework::AssetSystem::AssetStatus::AssetStatus_Unknown:
|
||||
case AzFramework::AssetSystem::AssetStatus::AssetStatus_Compiled:
|
||||
assetInfo.m_relativePath = "textures/defaults/missing.png.streamingimage";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the fallback image has been processed
|
||||
AzFramework::AssetSystem::AssetStatus status = AzFramework::AssetSystem::AssetStatus_Unknown;
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
status, &AzFramework::AssetSystemRequestBus::Events::CompileAssetSync, "textures/defaults/defaultnouvs.tif.streamingimage");
|
||||
|
||||
// Get the id of the fallback image
|
||||
Data::AssetInfo assetInfo;
|
||||
assetInfo.m_relativePath = "textures/defaults/defaultnouvs.tif.streamingimage";
|
||||
Data::AssetId assetId;
|
||||
status, &AzFramework::AssetSystemRequestBus::Events::CompileAssetSync, assetInfo.m_relativePath);
|
||||
|
||||
// Generate the id of the fallback image
|
||||
Data::AssetCatalogRequestBus::BroadcastResult(
|
||||
assetId, &Data::AssetCatalogRequestBus::Events::GenerateAssetIdTEMP,
|
||||
assetInfo.m_assetId, &Data::AssetCatalogRequestBus::Events::GenerateAssetIdTEMP,
|
||||
assetInfo.m_relativePath.c_str());
|
||||
|
||||
assetInfo.m_assetId = Data::AssetId(assetId.m_guid, StreamingImageAsset::GetImageAssetSubId());
|
||||
assetInfo.m_assetId.m_subId = StreamingImageAsset::GetImageAssetSubId();
|
||||
|
||||
// Register the fallback image with the asset catalog
|
||||
Data::AssetCatalogRequestBus::Broadcast(
|
||||
&Data::AssetCatalogRequestBus::Events::RegisterAsset, assetInfo.m_assetId, assetInfo);
|
||||
Data::AssetCatalogRequestBus::Broadcast(&Data::AssetCatalogRequestBus::Events::RegisterAsset, assetInfo.m_assetId, assetInfo);
|
||||
|
||||
// Use a default Image as a fallback
|
||||
// Return the asset id of the fallback image
|
||||
return assetInfo.m_assetId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"O3DE": {
|
||||
"Atom": {
|
||||
"RPI": {
|
||||
"UseDebugFallbackImages": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,8 @@
|
||||
"DynamicDrawSystemDescriptor": {
|
||||
"DynamicBufferPoolSize": 50331648 // 3 * 16 * 1024 * 1024 (for 3 frames)
|
||||
}
|
||||
}
|
||||
},
|
||||
"UseDebugFallbackImages": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user