3
0

EditorModeTintPass.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #include <Pass/Child/EditorModeTintPass.h>
  9. #include <PostProcess/PostProcessFeatureProcessor.h>
  10. #include <Atom/RPI.Public/RenderPipeline.h>
  11. #include <Atom/RPI.Public/Scene.h>
  12. #include <Atom/RPI.Public/View.h>
  13. // Temporary measure for setting the color tint pass shader parameters at runtime until GHI 3455 is implemented
  14. AZ_EDITOR_MODE_PASS_TRANSITION_CVARS(cl_editorModeTintPass, 0.0f, 0.0f, 0.0f, 1.0f);
  15. AZ_EDITOR_MODE_PASS_CVAR(float, cl_editorModeTintPass, TintAmount, 0.5f);
  16. AZ_EDITOR_MODE_PASS_CVAR(AZ::Color, cl_editorModeTintPass, TintColor, AZ::Color(0.0f, 0.0f, 0.0f, 0.0f));
  17. namespace AZ
  18. {
  19. namespace Render
  20. {
  21. RPI::Ptr<EditorModeTintPass> EditorModeTintPass::Create(const RPI::PassDescriptor& descriptor)
  22. {
  23. RPI::Ptr<EditorModeTintPass> pass = aznew EditorModeTintPass(descriptor);
  24. return AZStd::move(pass);
  25. }
  26. EditorModeTintPass::EditorModeTintPass(const RPI::PassDescriptor& descriptor)
  27. : EditorModeFeedbackChildPassBase(descriptor)
  28. {
  29. }
  30. void EditorModeTintPass::InitializeInternal()
  31. {
  32. EditorModeFeedbackChildPassBase::InitializeInternal();
  33. m_tintAmountIndex.Reset();
  34. }
  35. void EditorModeTintPass::FrameBeginInternal(FramePrepareParams params)
  36. {
  37. SetSrgConstants();
  38. EditorModeFeedbackChildPassBase::FrameBeginInternal(params);
  39. }
  40. void EditorModeTintPass::SetTintAmount(const float amount)
  41. {
  42. m_tintAmount = amount;
  43. }
  44. void EditorModeTintPass::SetTintColor(AZ::Color color)
  45. {
  46. m_tintColor = color;
  47. }
  48. void EditorModeTintPass::SetSrgConstants()
  49. {
  50. // Temporary measure for setting the pass shader parameters at runtime until GHI 3455 is implemented
  51. SetMinDepthTransitionValue(cl_editorModeTintPass_MinDepthTransitionValue);
  52. SetDepthTransitionStart(cl_editorModeTintPass_DepthTransitionStart);
  53. SetDepthTransitionDuration(cl_editorModeTintPass_DepthTransitionDuration);
  54. SetFinalBlendAmount(cl_editorModeTintPass_FinalBlendAmount);
  55. SetTintAmount(cl_editorModeTintPass_TintAmount);
  56. SetTintColor(cl_editorModeTintPass_TintColor);
  57. m_shaderResourceGroup->SetConstant(m_tintAmountIndex, m_tintAmount);
  58. m_shaderResourceGroup->SetConstant(m_tintColorIndex, m_tintColor);
  59. }
  60. } // namespace Render
  61. } // namespace AZ