DepthOfFieldCompositePass.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/FullscreenTrianglePass.h>
  10. #include <PostProcessing/PostProcessingShaderOptionBase.h>
  11. namespace AZ
  12. {
  13. namespace Render
  14. {
  15. //! Pass used to enabled/disabled debug colors by shader option.
  16. class DepthOfFieldCompositePass final
  17. : public RPI::FullscreenTrianglePass
  18. , public PostProcessingShaderOptionBase
  19. {
  20. AZ_RPI_PASS(DepthOfFieldCompositePass);
  21. public:
  22. AZ_RTTI(AZ::Render::DepthOfFieldCompositePass, "{7595A972-7ED5-46FE-BBE0-3262846E2964}", AZ::RPI::FullscreenTrianglePass);
  23. AZ_CLASS_ALLOCATOR(DepthOfFieldCompositePass, SystemAllocator);
  24. virtual ~DepthOfFieldCompositePass() = default;
  25. //! Creates a DepthOfFieldCompositePass
  26. static RPI::Ptr<DepthOfFieldCompositePass> Create(const RPI::PassDescriptor& descriptor);
  27. void SetEnabledDebugColoring(bool enabled);
  28. protected:
  29. // Pass behavior overrides...
  30. void InitializeInternal() override;
  31. void FrameBeginInternal(FramePrepareParams params) override;
  32. private:
  33. DepthOfFieldCompositePass(const RPI::PassDescriptor& descriptor);
  34. void InitializeShaderVariant();
  35. void UpdateCurrentShaderVariant();
  36. // Scope producer functions...
  37. void CompileResources(const RHI::FrameGraphCompileContext& context) override;
  38. void BuildCommandListInternal(const RHI::FrameGraphExecuteContext& context) override;
  39. bool m_needToUpdateShaderVariant = true;
  40. bool m_enabledDebugColoring = false;
  41. // SRG binding indices...
  42. RHI::ShaderInputNameIndex m_backBlendFactorDivision2Index = "m_backBlendFactorDivision2";
  43. RHI::ShaderInputNameIndex m_backBlendFactorDivision4Index = "m_backBlendFactorDivision4";
  44. RHI::ShaderInputNameIndex m_backBlendFactorDivision8Index = "m_backBlendFactorDivision8";
  45. RHI::ShaderInputNameIndex m_frontBlendFactorDivision2Index = "m_frontBlendFactorDivision2";
  46. RHI::ShaderInputNameIndex m_frontBlendFactorDivision4Index = "m_frontBlendFactorDivision4";
  47. RHI::ShaderInputNameIndex m_frontBlendFactorDivision8Index = "m_frontBlendFactorDivision8";
  48. // scale / offset to convert DofFactor to blend ratio for back buffer.
  49. AZStd::array<float, 2> m_backBlendFactorDivision2 = { { 0.0f, 0.0f } };
  50. AZStd::array<float, 2> m_backBlendFactorDivision4 = { { 0.0f, 0.0f } };
  51. AZStd::array<float, 2> m_backBlendFactorDivision8 = { { 0.0f, 0.0f } };
  52. // scale / offset to convert DofFactor to blend ratio for front buffer.
  53. AZStd::array<float, 2> m_frontBlendFactorDivision2 = { { 0.0f, 0.0f } };
  54. AZStd::array<float, 2> m_frontBlendFactorDivision4 = { { 0.0f, 0.0f } };
  55. AZStd::array<float, 2> m_frontBlendFactorDivision8 = { { 0.0f, 0.0f } };
  56. const AZ::Name m_optionName;
  57. const AZStd::vector<AZ::Name> m_optionValues;
  58. };
  59. } // namespace Render
  60. } // namespace AZ