MSAA_RPI_ExampleComponent.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. * its licensors.
  4. *
  5. * For complete copyright and license terms please see the LICENSE at the root of this
  6. * distribution (the "License"). All use of this software is governed by the License,
  7. * or, if provided, by the license below or the license accompanying this file. Do not
  8. * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. *
  11. */
  12. #pragma once
  13. #include <CommonSampleComponentBase.h>
  14. #include <AzCore/Component/EntityBus.h>
  15. #include <AzCore/Component/TickBus.h>
  16. #include <Atom/Feature/ImGui/ImGuiUtils.h>
  17. #include <AzFramework/Input/Events/InputChannelEventListener.h>
  18. #include <Atom/Bootstrap/DefaultWindowBus.h>
  19. #include <Utils/ImGuiSidebar.h>
  20. #include <Utils/Utils.h>
  21. #include <ExampleComponentBus.h>
  22. namespace AtomSampleViewer
  23. {
  24. //!
  25. //! This component creates a simple scene that tests the MSAA pipeline. It can test both MSAA enabled and disabled with the same scene
  26. //!
  27. class MSAA_RPI_ExampleComponent final
  28. : public CommonSampleComponentBase
  29. , public AZ::Render::Bootstrap::DefaultWindowNotificationBus::Handler
  30. , public AZ::TickBus::Handler
  31. , public ExampleComponentRequestBus::Handler
  32. {
  33. public:
  34. AZ_COMPONENT(MSAA_RPI_ExampleComponent, "{2BDCA64E-7E5F-49EE-ACF5-65C79C40840D}", CommonSampleComponentBase);
  35. static void Reflect(AZ::ReflectContext* context);
  36. void Activate() override;
  37. void Deactivate() override;
  38. private:
  39. void ActivateMSAAPipeline();
  40. void DeactivateMSAAPipeline();
  41. void ActivateIbl();
  42. void DeactivateIbl();
  43. void CreateMSAAPipeline(int numSamples);
  44. void DestroyMSAAPipeline();
  45. void ActivateModel();
  46. void DeactivateModel();
  47. // AZ::TickBus::Handler
  48. void OnTick(float deltaTime, AZ::ScriptTimePoint timePoint) override;
  49. // ExampleComponentRequestBus::Handler
  50. void ResetCamera() override;
  51. void DefaultWindowCreated() override;
  52. void EnableArcBallCameraController();
  53. void DisableArcBallCameraController();
  54. void OnModelReady(AZ::Data::Instance<AZ::RPI::Model> model);
  55. AZ::Data::Asset<AZ::RPI::MaterialAsset> GetMaterialAsset();
  56. AZ::Data::Asset<AZ::RPI::ModelAsset> GetModelAsset();
  57. void DrawSidebar();
  58. bool DrawSidebarModeChooser(bool refresh);
  59. bool DrawSideBarModelChooser(bool refresh);
  60. AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle;
  61. AZ::Render::MeshFeatureProcessorInterface::ModelChangedEvent::Handler m_meshChangedHandler
  62. {
  63. [&](AZ::Data::Instance<AZ::RPI::Model> model)
  64. {
  65. OnModelReady(model);
  66. }
  67. };
  68. AZ::RPI::RenderPipelinePtr m_msaaPipeline;
  69. AZ::RPI::RenderPipelinePtr m_originalPipeline;
  70. AZStd::shared_ptr<AZ::RPI::WindowContext> m_windowContext;
  71. Utils::DefaultIBL m_defaultIbl;
  72. ImGuiSidebar m_imguiSidebar;
  73. int m_numSamples = 1;
  74. int m_modelType = 0;
  75. AZ::Render::ImGuiActiveContextScope m_imguiScope;
  76. };
  77. } // namespace AtomSampleViewer