SilhouetteFeatureProcessor.h 2.1 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. #pragma once
  9. #include <Atom/RPI.Public/FeatureProcessor.h>
  10. namespace AZ::RPI
  11. {
  12. class Pass;
  13. class RasterPass;
  14. }
  15. namespace AZ::Render
  16. {
  17. // Adds a silhouette gather pass and a silhouette full screen pass for drawing and
  18. // blocking silhouettes
  19. // The gather pass draws silhoutte meshes that use the "Silhouette" Material type
  20. // to a render target, using the depth and stencil buffer to determine where to draw
  21. // The silhouette full screen pass then composites the render target with all the
  22. // silhouettes into the framebuffer and adds an outline.
  23. class SilhouetteFeatureProcessor final
  24. : public AZ::RPI::FeatureProcessor
  25. {
  26. public:
  27. AZ_CLASS_ALLOCATOR(SilhouetteFeatureProcessor, AZ::SystemAllocator)
  28. AZ_RTTI(AZ::Render::SilhouetteFeatureProcessor, "{E32ABBE6-2472-4404-AEDB-1CE7A12E7C43}", AZ::RPI::FeatureProcessor);
  29. static void Reflect(AZ::ReflectContext* context);
  30. SilhouetteFeatureProcessor();
  31. ~SilhouetteFeatureProcessor() override;
  32. //! Set the enabled state of the gather and composite passes
  33. //! @param enabled Whether to enable the passes or not
  34. void SetPassesEnabled(bool enabled);
  35. //! FeatureProcessor
  36. void Activate() override;
  37. void Deactivate() override;
  38. void AddRenderPasses(AZ::RPI::RenderPipeline* renderPipeline) override;
  39. //! RPI::SceneNotificationBus
  40. void OnRenderEnd() override;
  41. void OnRenderPipelineChanged(AZ::RPI::RenderPipeline* pipeline, AZ::RPI::SceneNotification::RenderPipelineChangeType changeType) override;
  42. bool NeedsCompositePass() const;
  43. private:
  44. void UpdatePasses(AZ::RPI::RenderPipeline* renderPipeline);
  45. AZ::RPI::RasterPass* m_rasterPass = nullptr;
  46. AZ::RPI::Pass* m_compositePass = nullptr;
  47. AZ::RPI::RenderPipeline* m_renderPipeline = nullptr;
  48. };
  49. }