ExposureExampleComponent.h 3.1 KB

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