EyeAdaptationPass.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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/Memory/SystemAllocator.h>
  10. #include <Atom/RHI/CommandList.h>
  11. #include <Atom/RHI/DrawItem.h>
  12. #include <Atom/RHI/ScopeProducer.h>
  13. #include <Atom/RHI.Reflect/ShaderResourceGroupLayoutDescriptor.h>
  14. #include <Atom/RHI.Reflect/ShaderInputNameIndex.h>
  15. #include <Atom/RPI.Public/Pass/ComputePass.h>
  16. #include <Atom/RPI.Public/Shader/Shader.h>
  17. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  18. namespace AZ
  19. {
  20. namespace Render
  21. {
  22. static const char* const EyeAdaptationPassTemplateName = "EyeAdaptationTemplate";
  23. static const char* const EyeAdaptationDataInputOutputSlotName = "EyeAdaptationDataInputOutput";
  24. //! The eye adaptation pass.
  25. //! This pass apply auto exposure control by like eye adaptation for input framebuffer color.
  26. class EyeAdaptationPass final
  27. : public RPI::ComputePass
  28. {
  29. AZ_RPI_PASS(EyeAdaptationPass);
  30. public:
  31. AZ_RTTI(EyeAdaptationPass, "{CC66CFD9-3266-4FD7-A5A8-ACA3753BDF4A}", RPI::ComputePass);
  32. AZ_CLASS_ALLOCATOR(EyeAdaptationPass, SystemAllocator);
  33. ~EyeAdaptationPass() = default;
  34. // Creates a EyeAdaptationPass
  35. static RPI::Ptr<EyeAdaptationPass> Create(const RPI::PassDescriptor& descriptor);
  36. // Check if we should enable of disable this pass
  37. bool IsEnabled() const override;
  38. protected:
  39. EyeAdaptationPass(const RPI::PassDescriptor& descriptor);
  40. void InitBuffer();
  41. // A StructuredBuffer for exposure calculation on the GPU.
  42. struct ExposureCalculationData
  43. {
  44. float m_exposureValue = 1.0f;
  45. float m_setValueTime = 0;
  46. };
  47. void BuildInternal() override;
  48. void FrameBeginInternal(FramePrepareParams params) override;
  49. AZ::Data::Instance<RPI::Buffer> m_buffer;
  50. // SRG binding indices...
  51. AZ::RHI::ShaderInputNameIndex m_exposureControlBufferInputIndex = "m_exposureControl";
  52. };
  53. } // namespace Render
  54. } // namespace AZ