EditorModeFeedbackChildPassBase.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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/Console/IConsole.h>
  10. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  11. #include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
  12. // Temporary measure for configuring editor mode feedback effects at runtime until GHI 3455 is implemented
  13. #define AZ_EDITOR_MODE_PASS_CVAR(TYPE, NAMESPACE, NAME, INITIAL_VALUE) \
  14. AZ_CVAR(TYPE, NAMESPACE##_##NAME, INITIAL_VALUE, nullptr, AZ::ConsoleFunctorFlags::Null, "");
  15. // Temporary measure for configuring editor mode depth transitions at runtime until GHI 3455 is implemented
  16. #define AZ_EDITOR_MODE_PASS_TRANSITION_CVARS(NAMESPACE, MIN_VALUE, START, DURATION, FINAL_BLEND) \
  17. AZ_EDITOR_MODE_PASS_CVAR(float, NAMESPACE, MinDepthTransitionValue, MIN_VALUE); \
  18. AZ_EDITOR_MODE_PASS_CVAR(float, NAMESPACE, DepthTransitionStart, START); \
  19. AZ_EDITOR_MODE_PASS_CVAR(float, NAMESPACE, DepthTransitionDuration, DURATION); \
  20. AZ_EDITOR_MODE_PASS_CVAR(float, NAMESPACE, FinalBlendAmount, FINAL_BLEND);
  21. namespace AZ
  22. {
  23. namespace Render
  24. {
  25. //! Base class to provide depth transitioning and final blend control to all visual effect passes of the editor mode
  26. //! feedback system.
  27. class EditorModeFeedbackChildPassBase
  28. : public AZ::RPI::FullscreenTrianglePass
  29. {
  30. public:
  31. AZ_RTTI(EditorModeFeedbackChildPassBase, "{F1F345E3-1396-47F7-9CA4-9AC87A2E9829}", AZ::RPI::FullscreenTrianglePass);
  32. AZ_CLASS_ALLOCATOR(EditorModeFeedbackChildPassBase, SystemAllocator);
  33. //! Creates a EditorModeFeedbackPassBase
  34. static RPI::Ptr<EditorModeFeedbackChildPassBase> Create(const RPI::PassDescriptor& descriptor);
  35. //! Sets the minimum blend amount that will be calculated through depth transitioning.
  36. void SetMinDepthTransitionValue(float minValue);
  37. //! Sets the start of depth transtion for non-mask effect blending.
  38. void SetDepthTransitionStart(float start);
  39. //! Sets the duration (depth) of the depth transition band (0.0 = no depth transitioning will be applied).
  40. void SetDepthTransitionDuration(float duration);
  41. //! Sets the final blend amount that is used to scale the calculated blend values.
  42. void SetFinalBlendAmount(float amount);
  43. protected:
  44. using AZ::RPI::FullscreenTrianglePass::FullscreenTrianglePass;
  45. struct DepthTransition
  46. {
  47. //! No depth transitioning by default
  48. float m_minDepthTransitionValue = 0.0f;
  49. float m_depthTransitionStart = 0.0f;
  50. float m_depthTransitionDuration = 0.0f;
  51. };
  52. EditorModeFeedbackChildPassBase(
  53. const RPI::PassDescriptor& descriptor, const DepthTransition& depthTransition, float finalBlendAmount);
  54. //! Pass behavior overrides
  55. void InitializeInternal() override;
  56. void FrameBeginInternal(FramePrepareParams params) override;
  57. private:
  58. //! Sets the shader constant values for the depth transition and final blend amount for editor mode feedback effects.
  59. void SetSrgConstants();
  60. RHI::ShaderInputNameIndex m_minDepthTransitionValueIndex = "m_minDepthTransitionValue";
  61. RHI::ShaderInputNameIndex m_depthTransitionStartIndex = "m_depthTransitionStart";
  62. RHI::ShaderInputNameIndex m_depthTransitionDurationIndex = "m_depthTransitionDuration";
  63. RHI::ShaderInputNameIndex m_finalBlendAmountIndex = "m_finalBlendAmount";
  64. DepthTransition m_depthransition;
  65. float m_finalBlendAmount = 1.0f;
  66. };
  67. } // Render
  68. } // namespace AZ