EditorModeOutlinePass.cpp 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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/EditorModeOutlinePass.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 outline pass shader parameters at runtime until GHI 3455 is implemented
  14. AZ_EDITOR_MODE_PASS_TRANSITION_CVARS(cl_editorModeOutlinePass, 0.0f, 0.0f, 0.0f, 1.0f);
  15. AZ_EDITOR_MODE_PASS_CVAR(float, cl_editorModeOutlinePass, LineThickness, 3.0f);
  16. AZ_EDITOR_MODE_PASS_CVAR(AZ::u8, cl_editorModeOutlinePass, OutlineStyle, 0);
  17. AZ_EDITOR_MODE_PASS_CVAR(AZ::Color, cl_editorModeOutlinePass, LineColor, AZ::Color(0.96f, 0.65f, 0.13f, 1.0f));
  18. namespace AZ
  19. {
  20. namespace Render
  21. {
  22. RPI::Ptr<EditorModeOutlinePass> EditorModeOutlinePass::Create(const RPI::PassDescriptor& descriptor)
  23. {
  24. RPI::Ptr<EditorModeOutlinePass> pass = aznew EditorModeOutlinePass(descriptor);
  25. return AZStd::move(pass);
  26. }
  27. EditorModeOutlinePass::EditorModeOutlinePass(const RPI::PassDescriptor& descriptor)
  28. : EditorModeFeedbackChildPassBase(descriptor, { 0.0f, 0.0f, 0.0f }, 1.0f)
  29. {
  30. }
  31. void EditorModeOutlinePass::InitializeInternal()
  32. {
  33. EditorModeFeedbackChildPassBase::InitializeInternal();
  34. m_lineThicknessIndex.Reset();
  35. m_lineColorIndex.Reset();
  36. m_outlineStyleIndex.Reset();
  37. }
  38. void EditorModeOutlinePass::FrameBeginInternal(FramePrepareParams params)
  39. {
  40. SetSrgConstants();
  41. EditorModeFeedbackChildPassBase::FrameBeginInternal(params);
  42. }
  43. void EditorModeOutlinePass::SetLineThickness(const float thickness)
  44. {
  45. m_lineThickness = thickness;
  46. }
  47. void EditorModeOutlinePass::SetLineColor(AZ::Color color)
  48. {
  49. m_lineColor = AZStd::move(color);
  50. }
  51. void EditorModeOutlinePass::SetOutlineStyle(OutlineStyle mode)
  52. {
  53. m_outlineStyle = mode;
  54. }
  55. void EditorModeOutlinePass::SetSrgConstants()
  56. {
  57. // Temporary measure for setting the pass shader parameters at runtime until GHI 3455 is implemented
  58. SetMinDepthTransitionValue(cl_editorModeOutlinePass_MinDepthTransitionValue);
  59. SetDepthTransitionStart(cl_editorModeOutlinePass_DepthTransitionStart);
  60. SetDepthTransitionDuration(cl_editorModeOutlinePass_DepthTransitionDuration);
  61. SetFinalBlendAmount(cl_editorModeOutlinePass_FinalBlendAmount);
  62. SetLineThickness(cl_editorModeOutlinePass_LineThickness);
  63. SetLineColor(cl_editorModeOutlinePass_LineColor);
  64. SetOutlineStyle(static_cast<OutlineStyle>(AZ::u32(cl_editorModeOutlinePass_OutlineStyle)));
  65. m_shaderResourceGroup->SetConstant(m_lineThicknessIndex, m_lineThickness);
  66. m_shaderResourceGroup->SetConstant(m_lineColorIndex, m_lineColor);
  67. m_shaderResourceGroup->SetConstant(m_outlineStyleIndex, static_cast<AZ::u32>(m_outlineStyle));
  68. }
  69. } // namespace Render
  70. } // namespace AZ