From 85b8177efa3e485e7c0738ec912e4533e77ad30a Mon Sep 17 00:00:00 2001 From: Chris Galvan Date: Tue, 1 Feb 2022 15:32:53 -0600 Subject: [PATCH] Added preset for converting gsi images Signed-off-by: Chris Galvan --- .../Assets/Config/GSI.preset | 66 +++++++++++++++++++ .../Assets/Config/GSI16.preset | 61 +++++++++++++++++ .../Assets/Config/GSI32.preset | 61 +++++++++++++++++ .../Assets/Config/GSI8.preset | 61 +++++++++++++++++ .../Assets/Config/ImageBuilder.settings | 6 +- .../Source/BuilderSettings/PresetSettings.cpp | 9 ++- .../Source/BuilderSettings/PresetSettings.h | 4 ++ .../Code/Source/Processing/ImageConvert.cpp | 13 +++- 8 files changed, 277 insertions(+), 4 deletions(-) create mode 100644 Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI.preset create mode 100644 Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI16.preset create mode 100644 Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI32.preset create mode 100644 Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI8.preset diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI.preset b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI.preset new file mode 100644 index 0000000000..6c99944afa --- /dev/null +++ b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI.preset @@ -0,0 +1,66 @@ +{ + "Type": "JsonSerialization", + "Version": 1, + "ClassName": "MultiplatformPresetSettings", + "ClassData": { + "DefaultPreset": { + "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", + "Name": "GSI", + "PixelFormat": "R8G8B8A8", + "UncompressedAutoPick": true, + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "PlatformsPresets": { + "android": { + "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", + "Name": "GSI", + "PixelFormat": "R8G8B8A8", + "UncompressedAutoPick": true, + "MaxTextureSize": 2048, + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "ios": { + "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", + "Name": "GSI", + "PixelFormat": "R8G8B8A8", + "UncompressedAutoPick": true, + "MaxTextureSize": 2048, + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "mac": { + "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", + "Name": "GSI", + "PixelFormat": "R8G8B8A8", + "UncompressedAutoPick": true, + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "provo": { + "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", + "Name": "GSI", + "PixelFormat": "R8G8B8A8", + "UncompressedAutoPick": true, + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + } + } + } +} diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI16.preset b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI16.preset new file mode 100644 index 0000000000..e6a127eb73 --- /dev/null +++ b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI16.preset @@ -0,0 +1,61 @@ +{ + "Type": "JsonSerialization", + "Version": 1, + "ClassName": "MultiplatformPresetSettings", + "ClassData": { + "DefaultPreset": { + "UUID": "{181FE328-5408-4722-895F-1BB61803997B}", + "Name": "GSI16", + "PixelFormat": "R16", + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "PlatformsPresets": { + "android": { + "UUID": "{181FE328-5408-4722-895F-1BB61803997B}", + "Name": "GSI16", + "PixelFormat": "R16", + "MaxTextureSize": 2048, + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "ios": { + "UUID": "{181FE328-5408-4722-895F-1BB61803997B}", + "Name": "GSI16", + "PixelFormat": "R16", + "MaxTextureSize": 2048, + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "mac": { + "UUID": "{181FE328-5408-4722-895F-1BB61803997B}", + "Name": "GSI16", + "PixelFormat": "R16", + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "provo": { + "UUID": "{181FE328-5408-4722-895F-1BB61803997B}", + "Name": "GSI16", + "PixelFormat": "R16", + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + } + } + } +} diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI32.preset b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI32.preset new file mode 100644 index 0000000000..0f79775f4a --- /dev/null +++ b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI32.preset @@ -0,0 +1,61 @@ +{ + "Type": "JsonSerialization", + "Version": 1, + "ClassName": "MultiplatformPresetSettings", + "ClassData": { + "DefaultPreset": { + "UUID": "{604FB174-7165-4F6E-889A-3B91DEC9311C}", + "Name": "GSI32", + "PixelFormat": "R32", + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "PlatformsPresets": { + "android": { + "UUID": "{604FB174-7165-4F6E-889A-3B91DEC9311C}", + "Name": "GSI32", + "PixelFormat": "R32", + "MaxTextureSize": 2048, + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "ios": { + "UUID": "{604FB174-7165-4F6E-889A-3B91DEC9311C}", + "Name": "GSI32", + "PixelFormat": "R32", + "MaxTextureSize": 2048, + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "mac": { + "UUID": "{604FB174-7165-4F6E-889A-3B91DEC9311C}", + "Name": "GSI32", + "PixelFormat": "R32", + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "provo": { + "UUID": "{604FB174-7165-4F6E-889A-3B91DEC9311C}", + "Name": "GSI32", + "PixelFormat": "R32", + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + } + } + } +} diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI8.preset b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI8.preset new file mode 100644 index 0000000000..a3e22bf6df --- /dev/null +++ b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI8.preset @@ -0,0 +1,61 @@ +{ + "Type": "JsonSerialization", + "Version": 1, + "ClassName": "MultiplatformPresetSettings", + "ClassData": { + "DefaultPreset": { + "UUID": "{84B1FE72-AD1A-4E50-83CC-4253ABA59733}", + "Name": "GSI8", + "PixelFormat": "R8", + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "PlatformsPresets": { + "android": { + "UUID": "{84B1FE72-AD1A-4E50-83CC-4253ABA59733}", + "Name": "GSI8", + "PixelFormat": "R8", + "MaxTextureSize": 2048, + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "ios": { + "UUID": "{84B1FE72-AD1A-4E50-83CC-4253ABA59733}", + "Name": "GSI8", + "PixelFormat": "R8", + "MaxTextureSize": 2048, + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "mac": { + "UUID": "{84B1FE72-AD1A-4E50-83CC-4253ABA59733}", + "Name": "GSI8", + "PixelFormat": "R8", + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "provo": { + "UUID": "{84B1FE72-AD1A-4E50-83CC-4253ABA59733}", + "Name": "GSI8", + "PixelFormat": "R8", + "DiscardAlpha": true, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + } + } + } +} diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/ImageBuilder.settings b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/ImageBuilder.settings index bba2855650..77e44e2e17 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/ImageBuilder.settings +++ b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/ImageBuilder.settings @@ -146,7 +146,11 @@ // decal "_decal": [ "Decal_AlbedoWithOpacity" ], // ui - "_ui": [ "UserInterface_Compressed","UserInterface_Lossless" ] + "_ui": [ "UserInterface_Compressed","UserInterface_Lossless" ], + "_gsi": [ "GSI" ], + "_gsi8": [ "GSI8" ], + "_gsi16": [ "GSI16" ], + "_gsi32": [ "GSI32" ] }, "DefaultPreset": "Albedo", "DefaultPresetAlpha": "AlbedoWithGenericAlpha" diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.cpp index 046c4faa87..56e16bdcc9 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.cpp @@ -50,7 +50,9 @@ namespace ImageProcessingAtom ->Field("NumberResidentMips", &PresetSettings::m_numResidentMips) ->Field("Swizzle", &PresetSettings::m_swizzle) ->Field("CubemapSettings", &PresetSettings::m_cubemapSetting) - ->Field("MipMapSetting", &PresetSettings::m_mipmapSetting); + ->Field("MipMapSetting", &PresetSettings::m_mipmapSetting) + ->Field("UncompressedAutoPick", &PresetSettings::m_uncompressedAutoPick) + ; serialize->Enum() ->Value("Uniform", RGBWeight::uniform) @@ -200,7 +202,9 @@ namespace ImageProcessingAtom m_glossFromNormals == other.m_glossFromNormals && m_swizzle == other.m_swizzle && m_isMipRenormalize == other.m_isMipRenormalize && - m_numResidentMips == other.m_numResidentMips; + m_numResidentMips == other.m_numResidentMips && + m_uncompressedAutoPick == other.m_uncompressedAutoPick + ; } void PresetSettings::DeepCopyMembers(const PresetSettings& other) @@ -237,6 +241,7 @@ namespace ImageProcessingAtom m_swizzle = other.m_swizzle; m_isMipRenormalize = other.m_isMipRenormalize; m_numResidentMips = other.m_numResidentMips; + m_uncompressedAutoPick = other.m_uncompressedAutoPick; } } diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.h b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.h index 3dc223cf80..89870f6099 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.h +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/PresetSettings.h @@ -103,6 +103,10 @@ 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; + protected: void DeepCopyMembers(const PresetSettings& other); }; diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp index 058daf7ca4..ec048e8758 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp @@ -535,7 +535,18 @@ namespace ImageProcessingAtom m_image->GetCompressOption().rgbWeight = m_input->m_presetSetting.GetColorWeight(); m_image->GetCompressOption().discardAlpha = m_input->m_presetSetting.m_discardAlpha; - m_image->ConvertFormat(m_input->m_presetSetting.m_pixelFormat); + // 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 + { + m_image->ConvertFormat(m_input->m_presetSetting.m_pixelFormat); + } return true; }