CheckerboardExampleComponent.h 2.3 KB

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