SMAANeighborhoodBlendingPass.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 <Atom/RPI.Public/Image/ImageSystemInterface.h>
  9. #include <Atom/RPI.Public/Pass/PassUtils.h>
  10. #include <Atom/RPI.Public/Pass/PassFactory.h>
  11. #include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
  12. #include <Atom/RPI.Public/RenderPipeline.h>
  13. #include <Atom/RPI.Public/RPIUtils.h>
  14. #include <Atom/RPI.Public/View.h>
  15. #include <Atom/RPI.Public/Shader/ShaderVariant.h>
  16. #include <Atom/RPI.Reflect/Pass/PassTemplate.h>
  17. #include <Atom/RPI.Reflect/Shader/ShaderAsset.h>
  18. #include <Atom/RHI/Factory.h>
  19. #include <Atom/RHI/FrameScheduler.h>
  20. #include <Atom/RHI/DevicePipelineState.h>
  21. #include <AzCore/Asset/AssetCommon.h>
  22. #include <AzCore/Asset/AssetManagerBus.h>
  23. #include <PostProcessing/SMAACommon.h>
  24. #include <PostProcessing/SMAANeighborhoodBlendingPass.h>
  25. namespace AZ
  26. {
  27. namespace Render
  28. {
  29. RPI::Ptr<SMAANeighborhoodBlendingPass> SMAANeighborhoodBlendingPass::Create(const RPI::PassDescriptor& descriptor)
  30. {
  31. return aznew SMAANeighborhoodBlendingPass(descriptor);
  32. }
  33. SMAANeighborhoodBlendingPass::SMAANeighborhoodBlendingPass(const RPI::PassDescriptor& descriptor)
  34. : SMAABasePass(descriptor)
  35. , m_blendingOutputModeOptionName(BlendingOutputModeOptionName)
  36. {
  37. }
  38. void SMAANeighborhoodBlendingPass::InitializeInternal()
  39. {
  40. SMAABasePass::InitializeInternal();
  41. m_renderTargetMetricsShaderInputIndex.Reset();
  42. }
  43. void SMAANeighborhoodBlendingPass::UpdateSRG()
  44. {
  45. m_shaderResourceGroup->SetConstant(m_renderTargetMetricsShaderInputIndex, m_renderTargetMetrics);
  46. }
  47. void SMAANeighborhoodBlendingPass::GetCurrentShaderOption(AZ::RPI::ShaderOptionGroup& shaderOption) const
  48. {
  49. switch (m_outputMode)
  50. {
  51. case SMAAOutputMode::BlendResult:
  52. shaderOption.SetValue(m_blendingOutputModeOptionName, AZ::Name("BlendingOutputMode::BlendResult"));
  53. break;
  54. case SMAAOutputMode::PassThrough:
  55. shaderOption.SetValue(m_blendingOutputModeOptionName, AZ::Name("BlendingOutputMode::PassThrough"));
  56. break;
  57. case SMAAOutputMode::EdgeTexture:
  58. shaderOption.SetValue(m_blendingOutputModeOptionName, AZ::Name("BlendingOutputMode::EdgeTexture"));
  59. break;
  60. case SMAAOutputMode::BlendWeightTexture:
  61. shaderOption.SetValue(m_blendingOutputModeOptionName, AZ::Name("BlendingOutputMode::BlendWeightTexture"));
  62. break;
  63. case SMAAOutputMode::BlendResultWithProvisionalTonemap:
  64. default:
  65. shaderOption.SetValue(m_blendingOutputModeOptionName, AZ::Name("BlendingOutputMode::BlendResultWithProvisionalTonemap"));
  66. break;
  67. }
  68. }
  69. void SMAANeighborhoodBlendingPass::SetOutputMode(SMAAOutputMode mode)
  70. {
  71. if (m_outputMode != mode)
  72. {
  73. m_outputMode = mode;
  74. InvalidateShaderVariant();
  75. }
  76. }
  77. } // namespace Render
  78. } // namespace AZ