ATOM-13512 Altering IBL ImageProcessor .preset Does Not Force Assets to Rebuild (#5639)
Changes include: - Move config files from ImageProcessingAtom/Config/ folder to ImageProcessingAtom/Assets/Config/ folder so it can be watched as source depencies. - Change GetSuggestedPreset function so it can return certain preset for certain file name. - Move file mask mappings from preset to ImageBuilder.settings. But the file masks in preset can still be used. - Changed from using project config folder's imageBuilder.Settings for override to using it as json merge patch. - Expose GetFileHash function in AssetBuilderSDK api. Signed-off-by: Qing Tao <55564570+VickyAtAZ@users.noreply.github.com>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <Processing/ImageConvert.h>
|
||||
#include <Processing/ImageAssetProducer.h>
|
||||
#include <Processing/ImageFlags.h>
|
||||
#include <Processing/Utils.h>
|
||||
#include <Converters/FIR-Weights.h>
|
||||
#include <Converters/Cubemap.h>
|
||||
#include <Converters/PixelOperation.h>
|
||||
@@ -229,12 +230,24 @@ namespace ImageProcessingAtom
|
||||
AZStd::unique_ptr<CubemapSettings>& cubemapSettings = m_input->m_presetSetting.m_cubemapSetting;
|
||||
if (cubemapSettings->m_generateIBLSpecular && !cubemapSettings->m_iblSpecularPreset.IsEmpty())
|
||||
{
|
||||
CreateIBLCubemap(cubemapSettings->m_iblSpecularPreset, SpecularCubemapSuffix, m_iblSpecularCubemapImage);
|
||||
bool success = CreateIBLCubemap(cubemapSettings->m_iblSpecularPreset, SpecularCubemapSuffix, m_iblSpecularCubemapImage);
|
||||
if (!success)
|
||||
{
|
||||
m_isSucceed = false;
|
||||
m_isFinished = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cubemapSettings->m_generateIBLDiffuse && !cubemapSettings->m_iblDiffusePreset.IsEmpty())
|
||||
{
|
||||
CreateIBLCubemap(cubemapSettings->m_iblDiffusePreset, DiffuseCubemapSuffix, m_iblDiffuseCubemapImage);
|
||||
bool success = CreateIBLCubemap(cubemapSettings->m_iblDiffusePreset, DiffuseCubemapSuffix, m_iblDiffuseCubemapImage);
|
||||
if (!success)
|
||||
{
|
||||
m_isSucceed = false;
|
||||
m_isFinished = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +264,12 @@ namespace ImageProcessingAtom
|
||||
{
|
||||
if (m_input->m_presetSetting.m_cubemapSetting->m_requiresConvolve)
|
||||
{
|
||||
FillCubemapMipmaps();
|
||||
bool success = FillCubemapMipmaps();
|
||||
if (!success)
|
||||
{
|
||||
m_isSucceed = false;
|
||||
m_isFinished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -268,9 +286,7 @@ namespace ImageProcessingAtom
|
||||
// get gloss from normal for all mipmaps and save to alpha channel
|
||||
if (m_input->m_presetSetting.m_glossFromNormals)
|
||||
{
|
||||
bool hasAlpha = (m_alphaContent == EAlphaContent::eAlphaContent_OnlyBlack
|
||||
|| m_alphaContent == EAlphaContent::eAlphaContent_OnlyBlackAndWhite
|
||||
|| m_alphaContent == EAlphaContent::eAlphaContent_Greyscale);
|
||||
bool hasAlpha = Utils::NeedAlphaChannel(m_alphaContent);
|
||||
|
||||
m_image->Get()->GlossFromNormals(hasAlpha);
|
||||
// set alpha content so it won't be ignored later.
|
||||
@@ -347,7 +363,11 @@ namespace ImageProcessingAtom
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_TracePrintf("Image Processing", "Image converted with preset [%s] [%s] and saved to [%s] (%d bytes) taking %f seconds\n",
|
||||
|
||||
[[maybe_unused]] const PixelFormatInfo* formatInfo = CPixelFormats::GetInstance().GetPixelFormatInfo(m_image->Get()->GetPixelFormat());
|
||||
AZ_TracePrintf("Image Processing", "Image [%dx%d] [%s] converted with preset [%s] [%s] and saved to [%s] (%d bytes) taking %f seconds\n",
|
||||
m_image->Get()->GetWidth(0), m_image->Get()->GetHeight(0),
|
||||
formatInfo->szName,
|
||||
m_input->m_presetSetting.m_name.GetCStr(),
|
||||
m_input->m_filePath.c_str(),
|
||||
m_input->m_outputFolder.c_str(), sizeTotal, m_processTime);
|
||||
@@ -421,6 +441,17 @@ namespace ImageProcessingAtom
|
||||
outHeight >>= 1;
|
||||
outReduce++;
|
||||
}
|
||||
|
||||
// resize to min texture size if it's smaller
|
||||
if (outWidth < presetSettings->m_minTextureSize)
|
||||
{
|
||||
outWidth = presetSettings->m_minTextureSize;
|
||||
}
|
||||
|
||||
if (outHeight < presetSettings->m_minTextureSize)
|
||||
{
|
||||
outHeight = presetSettings->m_minTextureSize;
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageConvertProcess::ConvertToLinear()
|
||||
@@ -647,7 +678,7 @@ namespace ImageProcessingAtom
|
||||
}
|
||||
else if (!CPixelFormats::GetInstance().IsImageSizeValid(dstFmt, dwWidth, dwHeight, false))
|
||||
{
|
||||
AZ_Warning("Image Processing", false, "Image size will be scaled for pixel format %s", CPixelFormats::GetInstance().GetPixelFormatInfo(dstFmt)->szName);
|
||||
AZ_TracePrintf("Image processing", "Image size will be scaled for pixel format %s\n", CPixelFormats::GetInstance().GetPixelFormatInfo(dstFmt)->szName);
|
||||
}
|
||||
|
||||
#if defined(AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS)
|
||||
@@ -758,7 +789,7 @@ namespace ImageProcessingAtom
|
||||
// in very rare user case, an old texture setting file may not have a preset. We fix it over here too.
|
||||
if (textureSettings.m_preset.IsEmpty())
|
||||
{
|
||||
textureSettings.m_preset = BuilderSettingManager::Instance()->GetSuggestedPreset(imageFilePath, srcImage);
|
||||
textureSettings.m_preset = BuilderSettingManager::Instance()->GetSuggestedPreset(imageFilePath);
|
||||
}
|
||||
|
||||
// Get preset
|
||||
@@ -795,7 +826,7 @@ namespace ImageProcessingAtom
|
||||
return process;
|
||||
}
|
||||
|
||||
void ImageConvertProcess::CreateIBLCubemap(PresetName preset, const char* fileNameSuffix, IImageObjectPtr& cubemapImage)
|
||||
bool ImageConvertProcess::CreateIBLCubemap(PresetName preset, const char* fileNameSuffix, IImageObjectPtr& cubemapImage)
|
||||
{
|
||||
const AZStd::string& platformId = m_input->m_platform;
|
||||
AZStd::string_view filePath;
|
||||
@@ -803,7 +834,7 @@ namespace ImageProcessingAtom
|
||||
if (presetSettings == nullptr)
|
||||
{
|
||||
AZ_Error("Image Processing", false, "Couldn't find preset for IBL cubemap generation");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// generate export file name
|
||||
@@ -838,14 +869,14 @@ namespace ImageProcessingAtom
|
||||
if (!imageConvertProcess)
|
||||
{
|
||||
AZ_Error("Image Processing", false, "Failed to create image convert process for the IBL cubemap");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
imageConvertProcess->ProcessAll();
|
||||
if (!imageConvertProcess->IsSucceed())
|
||||
{
|
||||
AZ_Error("Image Processing", false, "Image convert process for the IBL cubemap failed");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// append the output products to the job's product list
|
||||
@@ -853,6 +884,7 @@ namespace ImageProcessingAtom
|
||||
|
||||
// store the output cubemap so it can be accessed by unit tests
|
||||
cubemapImage = imageConvertProcess->m_image->Get();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConvertImageFile(const AZStd::string& imageFilePath, const AZStd::string& exportDir,
|
||||
|
||||
Reference in New Issue
Block a user