diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI.preset b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI.preset index 78f4c7ad76..1f4f455b89 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI.preset @@ -6,7 +6,7 @@ "DefaultPreset": { "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", "Name": "GSI", - "UncompressedAutoPick": true, + "OutputTypeHandling": "UseInputFormatAndBitDepth", "IsPowerOf2": true, "MipMapSetting": { "MipGenType": "Box" @@ -16,7 +16,7 @@ "android": { "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", "Name": "GSI", - "UncompressedAutoPick": true, + "OutputTypeHandling": "UseInputFormatAndBitDepth", "MaxTextureSize": 2048, "IsPowerOf2": true, "MipMapSetting": { @@ -26,7 +26,7 @@ "ios": { "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", "Name": "GSI", - "UncompressedAutoPick": true, + "OutputTypeHandling": "UseInputFormatAndBitDepth", "MaxTextureSize": 2048, "IsPowerOf2": true, "MipMapSetting": { @@ -36,7 +36,7 @@ "mac": { "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", "Name": "GSI", - "UncompressedAutoPick": true, + "OutputTypeHandling": "UseInputFormatAndBitDepth", "IsPowerOf2": true, "MipMapSetting": { "MipGenType": "Box" @@ -45,7 +45,7 @@ "provo": { "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", "Name": "GSI", - "UncompressedAutoPick": true, + "OutputTypeHandling": "UseInputFormatAndBitDepth", "IsPowerOf2": true, "MipMapSetting": { "MipGenType": "Box" diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.cpp index 56e16bdcc9..eb37f3e4b9 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.cpp @@ -51,7 +51,7 @@ namespace ImageProcessingAtom ->Field("Swizzle", &PresetSettings::m_swizzle) ->Field("CubemapSettings", &PresetSettings::m_cubemapSetting) ->Field("MipMapSetting", &PresetSettings::m_mipmapSetting) - ->Field("UncompressedAutoPick", &PresetSettings::m_uncompressedAutoPick) + ->Field("OutputTypeHandling", &PresetSettings::m_outputTypeHandling) ; serialize->Enum() @@ -132,6 +132,11 @@ namespace ImageProcessingAtom ->Value("R32", EPixelFormat::ePixelFormat_R32) ->Value("Unknown", EPixelFormat::ePixelFormat_Unknown) ; + + serialize->Enum() + ->Value("Default", OutputTypeHandling::USE_SPECIFIED_OUTPUT_TYPE) + ->Value("UseInputFormatAndBitDepth", OutputTypeHandling::USE_INPUT_FORMAT_AND_BIT_DEPTH) + ; } } @@ -203,7 +208,7 @@ namespace ImageProcessingAtom m_swizzle == other.m_swizzle && m_isMipRenormalize == other.m_isMipRenormalize && m_numResidentMips == other.m_numResidentMips && - m_uncompressedAutoPick == other.m_uncompressedAutoPick + m_outputTypeHandling == other.m_outputTypeHandling ; } @@ -241,7 +246,7 @@ namespace ImageProcessingAtom m_swizzle = other.m_swizzle; m_isMipRenormalize = other.m_isMipRenormalize; m_numResidentMips = other.m_numResidentMips; - m_uncompressedAutoPick = other.m_uncompressedAutoPick; + m_outputTypeHandling = other.m_outputTypeHandling; } } diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.h b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.h index 89870f6099..5caa49d4da 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.h +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.h @@ -25,6 +25,13 @@ namespace ImageProcessingAtom AZ_TYPE_INFO(PresetSettings, "{4F4DEC5C-48DD-40FD-97B4-5FB6FC7242E9}"); AZ_CLASS_ALLOCATOR(PresetSettings, AZ::SystemAllocator, 0); + //! Custom overrides for how to handle the output format + enum OutputTypeHandling + { + USE_SPECIFIED_OUTPUT_TYPE = 0, + USE_INPUT_FORMAT_AND_BIT_DEPTH + }; + PresetSettings(); PresetSettings(const PresetSettings& other); PresetSettings& operator= (const PresetSettings& other); @@ -103,9 +110,8 @@ namespace ImageProcessingAtom //"swizzle". need to be 4 character and each character need to be one of "rgba01" AZStd::string m_swizzle; - //! Convert to an uncompressed pixel format that automatically picks a preferred pixel - //! format based on the source input - bool m_uncompressedAutoPick = false; + //! Controls how the output type format is derived + OutputTypeHandling m_outputTypeHandling = USE_SPECIFIED_OUTPUT_TYPE; protected: void DeepCopyMembers(const PresetSettings& other); @@ -140,3 +146,10 @@ namespace ImageProcessingAtom }; } // namespace ImageProcessingAtom + +namespace AZ +{ + // Bind enums with uuids. Required for named enum support. + // Note: AZ_TYPE_INFO_SPECIALIZE has to be declared in AZ namespace + AZ_TYPE_INFO_SPECIALIZE(ImageProcessingAtom::PresetSettings::OutputTypeHandling, "{F919ECB6-BF80-4BEF-9E72-EA76504EBE9D}"); +} diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp index ec048e8758..0de941b85e 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp @@ -535,17 +535,20 @@ namespace ImageProcessingAtom m_image->GetCompressOption().rgbWeight = m_input->m_presetSetting.GetColorWeight(); m_image->GetCompressOption().discardAlpha = m_input->m_presetSetting.m_discardAlpha; - // If the m_uncompressedAutoPick flag is set, then let the converter pick - // a pixel format that best matches the source input format - if (m_input->m_presetSetting.m_uncompressedAutoPick) - { - EPixelFormat sourceInputFormat = m_input->m_inputImage->GetPixelFormat(); - m_image->ConvertFormat(sourceInputFormat); - } - // Otherwise, convert to the pixel format specified by the preset that was chosen - else + // Convert to a pixel format based on the desired handling + // The default behavior will choose the output format specified by the preset + switch (m_input->m_presetSetting.m_outputTypeHandling) { + case PresetSettings::OutputTypeHandling::USE_INPUT_FORMAT_AND_BIT_DEPTH: + { + EPixelFormat sourceInputFormat = m_input->m_inputImage->GetPixelFormat(); + m_image->ConvertFormat(sourceInputFormat); + } + break; + case PresetSettings::OutputTypeHandling::USE_SPECIFIED_OUTPUT_TYPE: + default: m_image->ConvertFormat(m_input->m_presetSetting.m_pixelFormat); + break; } return true;