CheckerboardExampleComponent.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 <Atom/Bootstrap/DefaultWindowBus.h>
  14. #include <Atom/Feature/ImGui/ImGuiUtils.h>
  15. #include <Atom/Feature/Mesh/MeshFeatureProcessorInterface.h>
  16. #include <AzCore/Component/Component.h>
  17. #include <AzCore/Component/EntityBus.h>
  18. #include <AzCore/Component/TickBus.h>
  19. #include <AzFramework/Entity/EntityContextBus.h>
  20. #include <Utils/ImGuiSidebar.h>
  21. #include <Utils/Utils.h>
  22. namespace AtomSampleViewer
  23. {
  24. // This component renders a model with pbr material using checkerboard render pipeline.
  25. class CheckerboardExampleComponent final
  26. : public AZ::Component
  27. , public AZ::Render::Bootstrap::DefaultWindowNotificationBus::Handler
  28. , public AZ::TickBus::Handler
  29. {
  30. public:
  31. AZ_COMPONENT(CheckerboardExampleComponent, "{0E5B3D5F-5BD2-41BF-BB1E-425AF976DFC9}");
  32. static void Reflect(AZ::ReflectContext* context);
  33. CheckerboardExampleComponent();
  34. ~CheckerboardExampleComponent() override = default;
  35. void Activate() override;
  36. void Deactivate() override;
  37. private:
  38. // AZ::Component overrides...
  39. bool ReadInConfig(const AZ::ComponentConfig* baseConfig) override;
  40. // DefaultWindowNotificationBus::Handler overrides...
  41. void DefaultWindowCreated() override;
  42. // AZ::TickBus::Handler overrides...
  43. void OnTick(float deltaTime, AZ::ScriptTimePoint timePoint) override;
  44. void ActivateCheckerboardPipeline();
  45. void DeactivateCheckerboardPipeline();
  46. // draw debug menu
  47. void DrawSidebar();
  48. // shader ball model
  49. AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle;
  50. // Not owned by this sample, we look this up based on the config from the
  51. // SampleComponentManager
  52. AZ::EntityId m_cameraEntityId;
  53. AzFramework::EntityContextId m_entityContextId;
  54. AZ::Render::MeshFeatureProcessorInterface* m_meshFeatureProcessor = nullptr;
  55. Utils::DefaultIBL m_defaultIbl;
  56. // for checkerboard render pipeline
  57. AZ::RPI::RenderPipelinePtr m_cbPipeline;
  58. AZ::RPI::RenderPipelinePtr m_originalPipeline;
  59. AZStd::shared_ptr<AZ::RPI::WindowContext> m_windowContext;
  60. // debug menu
  61. ImGuiSidebar m_imguiSidebar;
  62. AZ::Render::ImGuiActiveContextScope m_imguiScope;
  63. };
  64. } // namespace AtomSampleViewer