ExposureControlSettings.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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/RHI.Reflect/ShaderResourceGroupLayoutDescriptor.h>
  11. #include <Atom/RPI.Public/View.h>
  12. #include <Atom/Feature/PostProcess/ExposureControl/ExposureControlSettingsInterface.h>
  13. #include <PostProcess/PostProcessBase.h>
  14. namespace AZ
  15. {
  16. namespace Render
  17. {
  18. class PostProcessSettings;
  19. // Name of the buffer used for the exposure control feature
  20. static const char* const ExposureControlBufferName = "ExposureControlBuffer";
  21. // The post process sub-settings class for the exposure control feature
  22. class ExposureControlSettings final
  23. : public ExposureControlSettingsInterface
  24. , public PostProcessBase
  25. {
  26. friend class PostProcessSettings;
  27. friend class PostProcessFeatureProcessor;
  28. public:
  29. AZ_RTTI(ExposureControlSettings, "{51DAEA8B-0744-41C4-B494-387D78E7E7C0}", ExposureControlSettingsInterface, PostProcessBase);
  30. AZ_CLASS_ALLOCATOR(ExposureControlSettings, SystemAllocator);
  31. ExposureControlSettings(PostProcessFeatureProcessor* featureProcessor);
  32. ~ExposureControlSettings() = default;
  33. // ExposureControlSettingsInterface overrides...
  34. void OnConfigChanged() override;
  35. // Applies settings from this onto target using override settings and passed alpha value for blending
  36. void ApplySettingsTo(ExposureControlSettings* target, float alpha) const;
  37. void UpdateBuffer();
  38. const RHI::MultiDeviceBufferView* GetBufferView() const { return m_buffer->GetBufferView(); }
  39. // Generate all getters and override setters.
  40. // Declare non-override setters, which will be defined in the .cpp
  41. #define AZ_GFX_COMMON_PARAM(ValueType, Name, MemberName, DefaultValue) \
  42. ValueType Get##Name() const override { return MemberName; } \
  43. void Set##Name(ValueType val) override; \
  44. #define AZ_GFX_COMMON_OVERRIDE(ValueType, Name, MemberName, OverrideValueType) \
  45. OverrideValueType Get##Name##Override() const override { return MemberName##Override; } \
  46. void Set##Name##Override(OverrideValueType val) override { MemberName##Override = val; } \
  47. #include <Atom/Feature/ParamMacros/MapAllCommon.inl>
  48. #include <Atom/Feature/PostProcess/ExposureControl/ExposureControlParams.inl>
  49. #include <Atom/Feature/ParamMacros/EndParams.inl>
  50. private:
  51. // Generate members...
  52. #include <Atom/Feature/ParamMacros/StartParamMembers.inl>
  53. #include <Atom/Feature/PostProcess/ExposureControl/ExposureControlParams.inl>
  54. #include <Atom/Feature/ParamMacros/EndParams.inl>
  55. void Simulate(float deltaTime);
  56. bool InitCommonBuffer();
  57. void UpdateShaderParameters();
  58. void UpdateExposureControlRelatedPassParameters();
  59. void UpdateLuminanceHeatmap();
  60. PostProcessSettings* m_parentSettings = nullptr;
  61. bool m_shouldUpdatePassParameters = true;
  62. struct ShaderParameters
  63. {
  64. float m_exposureMin;
  65. float m_exposureMax;
  66. float m_speedUp;
  67. float m_speedDown;
  68. float m_compensationValue = 0.0f;
  69. uint32_t m_eyeAdaptationEnabled = 0;
  70. AZStd::array<uint32_t, 2> m_padding = { 0, 0 };
  71. };
  72. // The eye adaptation shader paraemters. This structure is same as ViewSrg::ExposureControlParameters.
  73. ShaderParameters m_shaderParameters;
  74. bool m_shouldUpdateShaderParameters = true;
  75. // Cache of the default view of the render pipeline to check change of the default view.
  76. const RPI::View* m_lastDefaultView = nullptr;
  77. AZ::Data::Instance<RPI::Buffer> m_buffer;
  78. const AZ::Name m_eyeAdaptationPassTemplateNameId;
  79. const AZ::Name m_luminanceHeatmapNameId;
  80. const AZ::Name m_luminanceHistogramGeneratorNameId;
  81. };
  82. }
  83. }