3
0

EditorModeBlurPass.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/EditorModeBlurPass.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 blur pass shader parameters at runtime until GHI 3455 is implemented
  14. AZ_EDITOR_MODE_PASS_TRANSITION_CVARS(cl_editorModeBlurPass, 0.0f, 0.0f, 20.0f, 1.0f);
  15. AZ_EDITOR_MODE_PASS_CVAR(float, cl_editorModeBlurPass, KernelHalfWidth, 5.0f);
  16. namespace AZ
  17. {
  18. namespace Render
  19. {
  20. RPI::Ptr<EditorModeBlurPass> EditorModeBlurPass::Create(const RPI::PassDescriptor& descriptor)
  21. {
  22. RPI::Ptr<EditorModeBlurPass> pass = aznew EditorModeBlurPass(descriptor);
  23. return AZStd::move(pass);
  24. }
  25. EditorModeBlurPass::EditorModeBlurPass(const RPI::PassDescriptor& descriptor)
  26. : EditorModeFeedbackChildPassBase(descriptor, { 0.0f, 0.0f, 20.0f }, 1.0f)
  27. {
  28. }
  29. void EditorModeBlurPass::InitializeInternal()
  30. {
  31. EditorModeFeedbackChildPassBase::InitializeInternal();
  32. m_kernelHalfWidthIndex.Reset();
  33. }
  34. void EditorModeBlurPass::FrameBeginInternal(FramePrepareParams params)
  35. {
  36. SetSrgConstants();
  37. EditorModeFeedbackChildPassBase::FrameBeginInternal(params);
  38. }
  39. void EditorModeBlurPass::SetKernelHalfWidth(const float width)
  40. {
  41. m_kernelHalfWidth = width;
  42. }
  43. void EditorModeBlurPass::SetSrgConstants()
  44. {
  45. // Temporary measure for setting the pass shader parameters at runtime until GHI 3455 is implemented
  46. SetMinDepthTransitionValue(cl_editorModeBlurPass_MinDepthTransitionValue);
  47. SetDepthTransitionStart(cl_editorModeBlurPass_DepthTransitionStart);
  48. SetDepthTransitionDuration(cl_editorModeBlurPass_DepthTransitionDuration);
  49. SetFinalBlendAmount(cl_editorModeBlurPass_FinalBlendAmount);
  50. SetKernelHalfWidth(cl_editorModeBlurPass_KernelHalfWidth);
  51. m_shaderResourceGroup->SetConstant(m_kernelHalfWidthIndex, m_kernelHalfWidth);
  52. }
  53. } // namespace Render
  54. } // namespace AZ