MSAA_RPI_ExampleComponent.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 <CommonSampleComponentBase.h>
  10. #include <AzCore/Component/EntityBus.h>
  11. #include <AzCore/Component/TickBus.h>
  12. #include <Atom/Feature/ImGui/ImGuiUtils.h>
  13. #include <AzFramework/Input/Events/InputChannelEventListener.h>
  14. #include <Atom/Bootstrap/DefaultWindowBus.h>
  15. #include <Utils/ImGuiSidebar.h>
  16. #include <Utils/Utils.h>
  17. #include <ExampleComponentBus.h>
  18. namespace AtomSampleViewer
  19. {
  20. //!
  21. //! This component creates a simple scene that tests the MSAA pipeline. It can test both MSAA enabled and disabled with the same scene
  22. //!
  23. class MSAA_RPI_ExampleComponent final
  24. : public CommonSampleComponentBase
  25. , public AZ::Render::Bootstrap::DefaultWindowNotificationBus::Handler
  26. , public AZ::TickBus::Handler
  27. , public ExampleComponentRequestBus::Handler
  28. {
  29. public:
  30. AZ_COMPONENT(MSAA_RPI_ExampleComponent, "{2BDCA64E-7E5F-49EE-ACF5-65C79C40840D}", CommonSampleComponentBase);
  31. static void Reflect(AZ::ReflectContext* context);
  32. void Activate() override;
  33. void Deactivate() override;
  34. private:
  35. // DefaultWindowNotificationBus::Handler
  36. void DefaultWindowCreated() override;
  37. // AZ::TickBus::Handler
  38. void OnTick(float deltaTime, AZ::ScriptTimePoint timePoint) override;
  39. // ExampleComponentRequestBus::Handler
  40. void ResetCamera() override;
  41. // helper functions
  42. void ChangeRenderPipeline();
  43. void ActivateIbl();
  44. void ActivateModel();
  45. void OnModelReady(AZ::Data::Instance<AZ::RPI::Model> model);
  46. AZ::Data::Asset<AZ::RPI::MaterialAsset> GetMaterialAsset();
  47. AZ::Data::Asset<AZ::RPI::ModelAsset> GetModelAsset();
  48. void DrawSidebar();
  49. bool DrawSidebarModeChooser(bool refresh);
  50. bool DrawSideBarModelChooser(bool refresh);
  51. // sample mesh
  52. int m_modelType = 0;
  53. AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle;
  54. // original render pipeline when the sample was started
  55. AZ::RPI::RenderPipelinePtr m_originalPipeline;
  56. // sample render pipeline, can be MSAA 2x/4x/8x or non-MSAA
  57. AZ::RPI::RenderPipelinePtr m_samplePipeline;
  58. // number of MSAA samples in the pipeline, controlled by the user
  59. int m_numSamples = 1;
  60. // flag indicating if the current pipeline is a non-MSAA pipeline
  61. bool m_isNonMsaaPipeline = false;
  62. // other state
  63. AZStd::shared_ptr<AZ::RPI::WindowContext> m_windowContext;
  64. Utils::DefaultIBL m_defaultIbl;
  65. ImGuiSidebar m_imguiSidebar;
  66. AZ::Render::ImGuiActiveContextScope m_imguiScope;
  67. };
  68. } // namespace AtomSampleViewer