BloomCompositePass.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 <Atom/RPI.Public/Pass/ComputePass.h>
  10. #include <Atom/RPI.Public/Pass/Pass.h>
  11. #include <Atom/RPI.Public/Pass/ParentPass.h>
  12. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  13. #include <Atom/RPI.Public/Shader/Shader.h>
  14. #include <Atom/RPI.Reflect/Pass/DownsampleMipChainPassData.h>
  15. #include <Atom/Feature/PostProcess/Bloom/BloomConstants.h>
  16. namespace AZ
  17. {
  18. namespace Render
  19. {
  20. class BloomCompositeChildPass;
  21. // Pass for combining contributions of all downsampled images to the render target
  22. class BloomCompositePass
  23. : public RPI::ParentPass
  24. {
  25. AZ_RPI_PASS(BloomCompositePass);
  26. public:
  27. AZ_RTTI(BloomCompositePass, "{02E41C48-5CC7-4277-B66E-009E4D6D32BA}", ParentPass);
  28. AZ_CLASS_ALLOCATOR(BloomCompositePass, SystemAllocator);
  29. virtual ~BloomCompositePass() = default;
  30. //! Creates a BloomCompositePass
  31. static RPI::Ptr<BloomCompositePass> Create(const RPI::PassDescriptor& descriptor);
  32. protected:
  33. BloomCompositePass(const RPI::PassDescriptor& descriptor);
  34. // Pass behaviour overrides...
  35. void BuildInternal() override;
  36. void FrameBeginInternal(FramePrepareParams params) override;
  37. void GetAttachmentInfo();
  38. void UpdateParameters();
  39. void BuildChildPasses();
  40. void UpdateChildren();
  41. void CreateBinding(BloomCompositeChildPass* pass, uint32_t mipLevel);
  42. RPI::DownsampleMipChainPassData m_passData;
  43. uint32_t m_inputWidth = 0;
  44. uint32_t m_inputHeight = 0;
  45. uint32_t m_outputWidth = 0;
  46. uint32_t m_outputHeight = 0;
  47. AZStd::vector<Vector3> m_tintData = {
  48. AZ::Render::Bloom::DefaultTint,
  49. AZ::Render::Bloom::DefaultTint,
  50. AZ::Render::Bloom::DefaultTint,
  51. AZ::Render::Bloom::DefaultTint,
  52. AZ::Render::Bloom::DefaultTint
  53. };
  54. float m_intensity = AZ::Render::Bloom::DefaultIntensity;
  55. bool m_enableBicubic = AZ::Render::Bloom::DefaultEnableBicubicFilter;
  56. };
  57. // Pass spawned by parent composite pass for additive upsampling
  58. class BloomCompositeChildPass
  59. : public RPI::ComputePass
  60. {
  61. AZ_RPI_PASS(BloomCompositeChildPass);
  62. friend class BloomBlurPass;
  63. public:
  64. AZ_RTTI(BloomCompositeChildPass, "{85D3FE9B-D347-40D6-B666-B4DF855F5B80}", RenderPass);
  65. AZ_CLASS_ALLOCATOR(BloomCompositeChildPass, SystemAllocator);
  66. virtual ~BloomCompositeChildPass() = default;
  67. //! Creates a BloomCompositeChildPass
  68. static RPI::Ptr<BloomCompositeChildPass> Create(const RPI::PassDescriptor& descriptor);
  69. void UpdateParameters(uint32_t sourceMip, uint32_t sourceImageWidth, uint32_t sourceImageHeight, uint32_t targetImageWidth, uint32_t targetImageHeight, bool enableBicubic, Vector3 tint, float intensity);
  70. protected:
  71. BloomCompositeChildPass(const RPI::PassDescriptor& descriptor);
  72. // Pass Behaviour Overrides...
  73. void FrameBeginInternal(FramePrepareParams params) override;
  74. RHI::ShaderInputNameIndex m_intensityInputIndex = "m_intensity";
  75. RHI::ShaderInputNameIndex m_sourceImageSizeInputIndex = "m_sourceImageSize";
  76. RHI::ShaderInputNameIndex m_sourceImageTexelSizeInputIndex = "m_sourceImageTexelSize";
  77. RHI::ShaderInputNameIndex m_targetImageSizeInputIndex = "m_targetImageSize";
  78. RHI::ShaderInputNameIndex m_sourceMipLevelInputIndex = "m_sourceMipLevel";
  79. RHI::ShaderInputNameIndex m_enableBicubicInputIndex = "m_enableBicubic";
  80. RHI::ShaderInputNameIndex m_tintInputIndex = "m_tint";
  81. uint32_t m_targetImageWidth;
  82. uint32_t m_targetImageHeight;
  83. };
  84. } // namespace RPI
  85. } // namespace AZ