ExposureExampleComponent.h 2.6 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 <Atom/Feature/CoreLights/PointLightFeatureProcessorInterface.h>
  11. #include <Atom/Feature/PostProcess/PostProcessFeatureProcessorInterface.h>
  12. #include <AzCore/Component/EntityBus.h>
  13. #include <AzCore/Component/TickBus.h>
  14. #include <Utils/Utils.h>
  15. #include <Utils/ImGuiSidebar.h>
  16. namespace AtomSampleViewer
  17. {
  18. /*
  19. * This component creates a simple scene to demonstrate the exposure feature.
  20. */
  21. class ExposureExampleComponent final
  22. : public CommonSampleComponentBase
  23. , public AZ::TickBus::Handler
  24. {
  25. public:
  26. AZ_COMPONENT(ExposureExampleComponent, "{90D874F5-6DE8-4CF3-A6DC-754E903544FF}", CommonSampleComponentBase);
  27. static void Reflect(AZ::ReflectContext* context);
  28. ExposureExampleComponent() = default;
  29. ~ExposureExampleComponent() override = default;
  30. void Activate() override;
  31. void Deactivate() override;
  32. private:
  33. using PointLightHandle = AZ::Render::PointLightFeatureProcessorInterface::LightHandle;
  34. PointLightHandle m_pointLight;
  35. // AZ::TickBus::Handler overrides...
  36. void OnTick(float deltaTime, AZ::ScriptTimePoint time);
  37. // AZ::EntityBus::MultiHandler...
  38. void OnEntityDestruction(const AZ::EntityId& entityId) override;
  39. void SetInitialCameraTransform();
  40. void EnableCameraController();
  41. void DisableCameraController();
  42. void CreateExposureEntity();
  43. void SetupScene();
  44. void SetupLights();
  45. void OnModelReady(AZ::Data::Instance<AZ::RPI::Model> model);
  46. void DrawSidebar();
  47. // owning entity
  48. AZ::Entity* m_exposureEntity = nullptr;
  49. bool m_cameraTransformInitialized = false;
  50. // GUI
  51. ImGuiSidebar m_imguiSidebar;
  52. // initialize flag
  53. bool m_isInitCamera = false;
  54. bool m_isInitParameters = false;
  55. // model
  56. AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle;
  57. bool m_sponzaAssetLoaded = false;
  58. // feature processors
  59. AZ::Render::PointLightFeatureProcessorInterface* m_pointLightFeatureProcessor = nullptr;
  60. AZ::Render::PostProcessFeatureProcessorInterface* m_postProcessFeatureProcessor = nullptr;
  61. AZ::Render::ExposureControlSettingsInterface* m_exposureControlSettings = nullptr;
  62. };
  63. } // namespace AtomSampleViewer