3
0

LookModificationSettings.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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/ReflectContext.h>
  10. #include <Atom/Feature/PostProcess/LookModification/LookModificationSettingsInterface.h>
  11. #include <PostProcess/PostProcessBase.h>
  12. #include <AzCore/Asset/AssetCommon.h>
  13. #include <Atom/RPI.Reflect/System/AnyAsset.h>
  14. #include <ACES/Aces.h>
  15. namespace AZ
  16. {
  17. namespace Render
  18. {
  19. class PostProcessSettings;
  20. struct LutBlendItem
  21. {
  22. //! The intensity of the LUT considered by itself compared to the ungraded base color.
  23. float m_intensity = 0.0f;
  24. //! The override intensity of this LUT over lower priority LUTs (based on the post process layers).
  25. //! During LUT blending, this override intensity is considered in conjunction with the LUTs own intensity.
  26. float m_overrideStrength = 0.0;
  27. //! Asset ID of LUT
  28. Data::Asset<RPI::AnyAsset> m_asset;
  29. //! Shaper preset type
  30. ShaperPresetType m_shaperPreset = AZ::Render::ShaperPresetType::Log2_48Nits;
  31. //! When shaper preset is custom, these values set min and max exposure.
  32. float m_customMinExposure = -6.5;
  33. float m_customMaxExposure = 6.5;
  34. HashValue64 GetHash(HashValue64 seed) const;
  35. };
  36. //! The post process sub-settings class for the look modification feature
  37. class LookModificationSettings final
  38. : public LookModificationSettingsInterface
  39. , public PostProcessBase
  40. {
  41. friend class PostProcessSettings;
  42. friend class PostProcessFeatureProcessor;
  43. public:
  44. AZ_RTTI(LookModificationSettings, "{244F5635-C5CA-412F-AD3D-49D55A771EB1}", LookModificationSettingsInterface, PostProcessBase);
  45. AZ_CLASS_ALLOCATOR(LookModificationSettings, SystemAllocator);
  46. static const uint32_t MaxBlendLuts = 4;
  47. LookModificationSettings(PostProcessFeatureProcessor* featureProcessor);
  48. ~LookModificationSettings() = default;
  49. //! LookModificationSettingsInterface overrides...
  50. void OnConfigChanged() override;
  51. //! Applies settings from this onto target using override settings and passed alpha value for blending
  52. void ApplySettingsTo(LookModificationSettings* target, float alpha) const;
  53. //! Add a LUT blending item to the stack
  54. void AddLutBlend(LutBlendItem lutBlendItem);
  55. //! Should be called to prepare the contents in the LUT blending stack before blending.
  56. void PrepareLutBlending();
  57. //! Returns the size of the LUT blending stack
  58. size_t GetLutBlendStackSize();
  59. //! Retrive the LUT blending item from the stack at the given index
  60. LutBlendItem& GetLutBlendItem(size_t lutIndex);
  61. //! Get a hash for this setting
  62. HashValue64 GetHash() const;
  63. // Generate all getters and override setters.
  64. // Declare non-override setters, which will be defined in the .cpp
  65. #define AZ_GFX_COMMON_PARAM(ValueType, Name, MemberName, DefaultValue) \
  66. ValueType Get##Name() const override { return MemberName; } \
  67. void Set##Name(ValueType val) override \
  68. { \
  69. MemberName = val; \
  70. } \
  71. #define AZ_GFX_COMMON_OVERRIDE(ValueType, Name, MemberName, OverrideValueType) \
  72. OverrideValueType Get##Name##Override() const override { return MemberName##Override; } \
  73. void Set##Name##Override(OverrideValueType val) override { MemberName##Override = val; } \
  74. #include <Atom/Feature/ParamMacros/MapAllCommon.inl>
  75. #include <Atom/Feature/PostProcess/LookModification/LookModificationParams.inl>
  76. #include <Atom/Feature/ParamMacros/EndParams.inl>
  77. private:
  78. // Generate members...
  79. #include <Atom/Feature/ParamMacros/StartParamMembers.inl>
  80. #include <Atom/Feature/PostProcess/LookModification/LookModificationParams.inl>
  81. #include <Atom/Feature/ParamMacros/EndParams.inl>
  82. void Simulate(float deltaTime);
  83. PostProcessSettings* m_parentSettings = nullptr;
  84. AZStd::vector<LutBlendItem> m_lutBlendStack;
  85. bool m_preparedForBlending = false;
  86. };
  87. }
  88. }