PresetSettings.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/RTTI/TypeInfo.h>
  10. #include <AzCore/Asset/AssetCommon.h>
  11. #include <BuilderSettings/ImageProcessingDefines.h>
  12. #include <BuilderSettings/CubemapSettings.h>
  13. #include <BuilderSettings/MipmapSettings.h>
  14. #include <Atom/ImageProcessing/PixelFormats.h>
  15. namespace ImageProcessingAtom
  16. {
  17. //settings for texture process preset
  18. class PresetSettings
  19. {
  20. public:
  21. AZ_TYPE_INFO(PresetSettings, "{4F4DEC5C-48DD-40FD-97B4-5FB6FC7242E9}");
  22. AZ_CLASS_ALLOCATOR(PresetSettings, AZ::SystemAllocator, 0);
  23. PresetSettings();
  24. PresetSettings(const PresetSettings& other);
  25. PresetSettings& operator= (const PresetSettings& other);
  26. bool operator== (const PresetSettings& other) const;
  27. static void Reflect(AZ::ReflectContext* context);
  28. // unique id for the preset
  29. // this uuid will be deprecated. The preset name will be used as an unique id for the preset
  30. AZ::Uuid m_uuid = 0;
  31. PresetName m_name;
  32. //a brief description for the usage of this Preset
  33. AZStd::string m_description;
  34. // Controls whether this preset only invokes IBL presets and does not generate its own output product
  35. bool m_generateIBLOnly = false;
  36. //misc options
  37. // "rgbweights". specify preset for weighting of R,G,B channels (used by compressor)
  38. RGBWeight m_rgbWeight = RGBWeight::uniform;
  39. ColorSpace m_srcColorSpace = ColorSpace::sRGB;
  40. ColorSpace m_destColorSpace = ColorSpace::autoSelect;
  41. // file masks used for helping select default preset and option preset list in texture property dialog
  42. AZStd::vector<FileMask> m_fileMasks;
  43. // "ser". Whether to enable suppress reduce resolution (m_sizeReduceLevel) during loading, 0(default)
  44. bool m_suppressEngineReduce = false;
  45. //pixel format
  46. EPixelFormat m_pixelFormat = EPixelFormat::ePixelFormat_R8G8B8A8;
  47. //pixel format for image which only contains alpha channel. this is for if we need to save alpha channel into a separate image
  48. EPixelFormat m_pixelFormatAlpha = EPixelFormat::ePixelFormat_A8;
  49. bool m_discardAlpha = false;
  50. // Resolution related settings
  51. // "maxtexturesize", upper limit of the resolution of generated textures. It should be a power-of-2 number larger than 1
  52. // resulting texture will be downscaled if its width or height larger than this value
  53. // 0 - no upper resolution limit (default)
  54. AZ::u32 m_maxTextureSize = 0;
  55. // "mintexturesize", lower limit of the resolution of generated textures.It should be a power-of-2 number larger than 1
  56. // resulting texture will be upscaled if its width or height smaller than this value
  57. // 0 - no lower resolution limit (default)
  58. AZ::u32 m_minTextureSize = 0;
  59. bool m_isPowerOf2 = false;
  60. //"reduce", 0=no size reduce /1=half resolution /2=quarter resolution, etc"
  61. AZ::u32 m_sizeReduceLevel = 0;
  62. //settings for cubemap generation. it's null if this preset is not for cubemap.
  63. //"cm" equals 1 to enable cubemap in rc.ini
  64. AZStd::unique_ptr<CubemapSettings> m_cubemapSetting;
  65. //settings for mipmap generation. it's null if this preset disable mipmap.
  66. AZStd::unique_ptr<MipmapSettings> m_mipmapSetting;
  67. //some specific settings
  68. // "colorchart". This is to indicate if need to extract color chart from the image and output the color chart data.
  69. // This is very specific usage for cryEngine. Check ColorChart.cpp for better explanation.
  70. bool m_isColorChart = false;
  71. //"highpass". Defines which mip level is subtracted when applying the high pass filter
  72. //this is only used for terrain asset. we might remove it later since it can be done with source image directly
  73. AZ::u32 m_highPassMip = 0;
  74. //"glossfromnormals". Bake normal variance into smoothness stored in alpha channel
  75. AZ::u32 m_glossFromNormals = 0;
  76. //"mipnormalize". need normalize the rgb
  77. bool m_isMipRenormalize = false;
  78. //function to get color's rgb weight in vec3 based on m_rgbWeight enum
  79. //this is useful for squisher compression
  80. AZ::Vector3 GetColorWeight();
  81. //the number of resident mips within the StreamingImageAsset's tail mip chain. When the m_numResidentMips is
  82. //set to 0, the StreamingImageAsset will contain as many mips as possible (starting from the lowest resolution)
  83. //that add up to 64K or lower
  84. AZ::u8 m_numResidentMips = 0;
  85. //legacy options might be removed later
  86. //"glosslegacydist". If the gloss map use legacy distribution. NW is still using legacy dist
  87. bool m_isLegacyGloss = false;
  88. //"swizzle". need to be 4 character and each character need to be one of "rgba01"
  89. AZStd::string m_swizzle;
  90. protected:
  91. void DeepCopyMembers(const PresetSettings& other);
  92. };
  93. class MultiplatformPresetSettings
  94. {
  95. public:
  96. AZ_TYPE_INFO(MultiplatformPresetSettings, "{05603AB1-FFC2-48F2-8322-BD265D6FB321}");
  97. AZ_CLASS_ALLOCATOR(MultiplatformPresetSettings, AZ::SystemAllocator, 0);
  98. static void Reflect(AZ::ReflectContext* context);
  99. const PresetSettings* GetPreset(const PlatformName& platform) const;
  100. const PresetSettings& GetDefaultPreset() const;
  101. //! Clear the preset data for each platform
  102. void ClearPlatformPresets();
  103. // functions to set the presets.
  104. void SetDefaultPreset(const PresetSettings& preset);
  105. void SetPresetForPlatform(const PresetSettings& preset, const PlatformName& platform);
  106. void SetPresetName(const PresetName& name);
  107. const PresetName& GetPresetName() const;
  108. AZ::Uuid GetPresetId() const;
  109. private:
  110. PresetSettings m_defaultPreset;
  111. AZStd::unordered_map<PlatformName, PresetSettings> m_presets;
  112. };
  113. } // namespace ImageProcessingAtom