SMAABlendingWeightCalculationPass.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 <Atom/RPI.Public/Image/StreamingImage.h>
  10. #include <PostProcessing/SMAABasePass.h>
  11. namespace AZ
  12. {
  13. namespace Render
  14. {
  15. static const char* const SMAABlendingWeightCalculationPassTemplateName = "SMAABlendingWeightCalculationTemplate";
  16. //! SMAA blending weight calculation pass implementation. The second pass of the SMAA uses the edge information generated by
  17. //! the first pass to determine the contribution of corresponding edge pixels to the edge geometry and thus to calculate
  18. //! their blending weight with neighbour pixels to generate a blending weight texture as output.
  19. class SMAABlendingWeightCalculationPass final
  20. : public SMAABasePass
  21. {
  22. public:
  23. AZ_RTTI(SMAABlendingWeightCalculationPass, "{989CD6FD-41E4-4F2A-99D0-40A4BA74FE95}", SMAABasePass);
  24. AZ_CLASS_ALLOCATOR(SMAABlendingWeightCalculationPass, SystemAllocator);
  25. virtual ~SMAABlendingWeightCalculationPass() = default;
  26. //! Creates a SMAABlendingWeightCalculationPass
  27. static RPI::Ptr<SMAABlendingWeightCalculationPass> Create(const RPI::PassDescriptor& descriptor);
  28. void SetMaxSearchSteps(int steps);
  29. void SetMaxSearchStepsDiagonal(int steps);
  30. void SetCornerRounding(int cornerRounding);
  31. void SetDiagonalDetectionEnable(bool enable);
  32. void SetCornerDetectionEnable(bool enable);
  33. private:
  34. SMAABlendingWeightCalculationPass(const RPI::PassDescriptor& descriptor);
  35. // Pass behavior overrides...
  36. void InitializeInternal() override;
  37. // SMAABasePass functions...
  38. void UpdateSRG() override;
  39. void GetCurrentShaderOption(AZ::RPI::ShaderOptionGroup& shaderOption) const override;
  40. AZ::Data::Instance<AZ::RPI::StreamingImage> m_areaTexture;
  41. AZ::Data::Instance<AZ::RPI::StreamingImage> m_searchTexture;
  42. RHI::ShaderInputNameIndex m_areaTextureShaderInputIndex = "m_areaTexture";
  43. RHI::ShaderInputNameIndex m_searchTextureShaderInputIndex = "m_searchTexture";
  44. RHI::ShaderInputNameIndex m_renderTargetMetricsShaderInputIndex = "m_renderTargetMetrics";
  45. RHI::ShaderInputNameIndex m_maxSearchStepsShaderInputIndex = "m_maxSearchSteps";
  46. RHI::ShaderInputNameIndex m_maxSearchStepsDiagonalShaderInputIndex = "m_maxSearchStepsDiagonal";
  47. RHI::ShaderInputNameIndex m_cornerRoundingShaderInputIndex = "m_cornerRounding";
  48. const AZ::Name m_enableDiagonalDetectionFeatureOptionName;
  49. const AZ::Name m_enableCornerDetectionFeatureOptionName;
  50. // How many steps to be used in horizontal/vertical search process. For details please check comment related to SMAA_MAX_SEARCH_STEPS in SMAA.azsli.
  51. int m_maxSearchSteps = 32;
  52. // How many steps to be used in diagonal search process. For details please check comment related to SMAA_MAX_SEARCH_STEPS_DIAG in SMAA.azsli.
  53. int m_maxSearchStepsDiagonal = 16;
  54. // This is a tweak value for the sharp corner feature. For details please check comment related to SMAA_CORNER_ROUNDING in SMAA.azsli.
  55. int m_cornerRounding = 25;
  56. // Diagonal edge detection feature flag. For details please check comment related to SMAA_DISABLE_DIAG_DETECTION in SMAA.azsli.
  57. bool m_enableDiagonalDetection = true;
  58. // Corner detection feature flag. For details please check comment related to SMAA_DISABLE_CORNER_DETECTION in SMAA.azsli.
  59. bool m_enableCornerDetection = true;
  60. };
  61. } // namespace Render
  62. } // namespace AZ