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..21c44ce271 --- /dev/null +++ b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/GSI.preset @@ -0,0 +1,56 @@ +{ + "Type": "JsonSerialization", + "Version": 1, + "ClassName": "MultiplatformPresetSettings", + "ClassData": { + "DefaultPreset": { + "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", + "Name": "GSI", + "OutputTypeHandling": "UseInputFormat", + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "PlatformsPresets": { + "android": { + "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", + "Name": "GSI", + "OutputTypeHandling": "UseInputFormat", + "MaxTextureSize": 2048, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "ios": { + "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", + "Name": "GSI", + "OutputTypeHandling": "UseInputFormat", + "MaxTextureSize": 2048, + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "mac": { + "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", + "Name": "GSI", + "OutputTypeHandling": "UseInputFormat", + "IsPowerOf2": true, + "MipMapSetting": { + "MipGenType": "Box" + } + }, + "provo": { + "UUID": "{C5E76E09-39FA-411F-B2E2-15B47BB6AB5F}", + "Name": "GSI", + "OutputTypeHandling": "UseInputFormat", + "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..e78dfe88b6 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("OutputTypeHandling", &PresetSettings::m_outputTypeHandling) + ; serialize->Enum() ->Value("Uniform", RGBWeight::uniform) @@ -130,6 +132,11 @@ namespace ImageProcessingAtom ->Value("R32", EPixelFormat::ePixelFormat_R32) ->Value("Unknown", EPixelFormat::ePixelFormat_Unknown) ; + + serialize->Enum() + ->Value("Default", OutputTypeHandling::UseSpecifiedOutputType) + ->Value("UseInputFormat", OutputTypeHandling::UseInputFormat) + ; } } @@ -200,7 +207,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_outputTypeHandling == other.m_outputTypeHandling + ; } void PresetSettings::DeepCopyMembers(const PresetSettings& other) @@ -237,6 +246,7 @@ namespace ImageProcessingAtom m_swizzle = other.m_swizzle; m_isMipRenormalize = other.m_isMipRenormalize; m_numResidentMips = other.m_numResidentMips; + 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 3dc223cf80..348fff989d 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 + { + UseSpecifiedOutputType = 0, + UseInputFormat + }; + PresetSettings(); PresetSettings(const PresetSettings& other); PresetSettings& operator= (const PresetSettings& other); @@ -103,6 +110,9 @@ namespace ImageProcessingAtom //"swizzle". need to be 4 character and each character need to be one of "rgba01" AZStd::string m_swizzle; + //! Controls how the output type format is derived + OutputTypeHandling m_outputTypeHandling = UseSpecifiedOutputType; + protected: void DeepCopyMembers(const PresetSettings& other); }; @@ -136,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 058daf7ca4..f2a071a2e5 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp @@ -535,7 +535,21 @@ 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); + // Convert to a pixel format based on the desired handling + // The default behavior will choose the output format specified by the preset + EPixelFormat outputFormat; + switch (m_input->m_presetSetting.m_outputTypeHandling) + { + case PresetSettings::OutputTypeHandling::UseInputFormat: + outputFormat = m_input->m_inputImage->GetPixelFormat(); + break; + case PresetSettings::OutputTypeHandling::UseSpecifiedOutputType: + default: + outputFormat = m_input->m_presetSetting.m_pixelFormat; + break; + } + + m_image->ConvertFormat(outputFormat); return true; }