SkyAtmosphereComponentController.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 <AzCore/Component/Component.h>
  10. #include <AzCore/Component/TransformBus.h>
  11. #include <AzCore/Component/EntityBus.h>
  12. #include <Atom/Feature/SkyAtmosphere/SkyAtmosphereFeatureProcessorInterface.h>
  13. #include <AtomLyIntegration/CommonFeatures/SkyAtmosphere/SkyAtmosphereBus.h>
  14. namespace AZ::Render
  15. {
  16. class SkyAtmosphereComponentController final
  17. : public TransformNotificationBus::MultiHandler
  18. , public SkyAtmosphereRequestBus::Handler
  19. , public EntityBus::Handler
  20. {
  21. public:
  22. friend class EditorSkyAtmosphereComponent;
  23. AZ_TYPE_INFO(AZ::Render::SkyAtmosphereComponentController, "{CB3DC903-ADAD-4127-9740-2D28AA890C2F}");
  24. static void Reflect(AZ::ReflectContext* context);
  25. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  26. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  27. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  28. SkyAtmosphereComponentController() = default;
  29. SkyAtmosphereComponentController(const SkyAtmosphereComponentConfig& config);
  30. void Activate(EntityId entityId);
  31. void Deactivate();
  32. void SetConfiguration(const SkyAtmosphereComponentConfig& config);
  33. const SkyAtmosphereComponentConfig& GetConfiguration() const;
  34. protected:
  35. const SkyAtmosphereParams& GetUpdatedSkyAtmosphereParams();
  36. private:
  37. AZ_DISABLE_COPY(SkyAtmosphereComponentController);
  38. //! SkyAtmosphereRequestBus
  39. void SetEnabled(bool enabled) override;
  40. bool GetEnabled() override;
  41. void SetPlanetOriginMode(SkyAtmosphereComponentConfig::AtmosphereOrigin mode) override;
  42. SkyAtmosphereComponentConfig::AtmosphereOrigin GetPlanetOriginMode() override;
  43. void SetAtmosphereHeight(float atmosphereHeightKm) override;
  44. float GetAtmosphereHeight() override;
  45. void SetPlanetRadius(float planetRadiusKm) override;
  46. float GetPlanetRadius() override;
  47. void SetGroundAlbedo(const AZ::Vector3& groundAlbedo) override;
  48. AZ::Vector3 GetGroundAlbedo() override;
  49. //! Atmosphere
  50. void SetLuminanceFactor(const AZ::Vector3& luminanceFactor) override;
  51. AZ::Vector3 GetLuminanceFactor() override;
  52. void SetMieAbsorption(const AZ::Vector3& mieAbsorption) override;
  53. AZ::Vector3 GetMieAbsorption() override;
  54. void SetMieExpDistribution(float mieExpDistribution) override;
  55. float GetMieExpDistribution() override;
  56. void SetMieScattering(const AZ::Vector3& mieScattering) override;
  57. AZ::Vector3 GetMieScattering() override;
  58. void SetRayleighExpDistribution(float rayleighExpDistribution) override;
  59. float GetRayleighExpDistribution() override;
  60. void SetRayleighScattering(const AZ::Vector3& rayleighScattering) override;
  61. AZ::Vector3 GetRayleighScattering() override;
  62. void SetMaxSamples(uint8_t maxSamples) override;
  63. uint8_t GetMaxSamples() override;
  64. void SetMinSamples(uint8_t minSamples) override;
  65. uint8_t GetMinSamples() override;
  66. //! Sun
  67. void SetSunEnabled(bool enabled) override;
  68. bool GetSunEnabled() override;
  69. void SetSunEntityId(AZ::EntityId entityId) override;
  70. AZ::EntityId GetSunEntityId() override;
  71. void SetSunColor(const AZ::Color sunColor) override;
  72. AZ::Color GetSunColor() override;
  73. void SetSunLuminanceFactor(float factor) override;
  74. float GetSunLuminanceFactor() override;
  75. void SetSunLimbColor(const AZ::Color sunLimbColor) override;
  76. AZ::Color GetSunLimbColor() override;
  77. void SetSunFalloffFactor(float factor) override;
  78. float GetSunFalloffFactor() override;
  79. void SetSunRadiusFactor(float factor) override;
  80. float GetSunRadiusFactor() override;
  81. void SetSunDirection(const AZ::Vector3& sunDirection) override;
  82. AZ::Vector3 GetSunDirection() override;
  83. //! Advanced
  84. void SetFastSkyEnabled(bool enabled) override;
  85. bool GetFastSkyEnabled() override;
  86. void SetFastAerialPerspectiveEnabled(bool enabled) override;
  87. bool GetFastAerialPerspectiveEnabled() override;
  88. void SetAerialPerspectiveEnabled(bool enabled) override;
  89. bool GetAerialPerspectiveEnabled() override;
  90. void SetNearClip(float nearClip) override;
  91. float GetNearClip() override;
  92. void SetNearFadeDistance(float nearFadeDistance) override;
  93. float GetNearFadeDistance() override;
  94. void SetAerialDepthFactor(float aerialDepthFactor) override;
  95. float GetAerialDepthFactor() override;
  96. void SetShadowsEnabled(bool enabled) override;
  97. bool GetShadowsEnabled() override;
  98. void OnParamUpdated();
  99. //! TransformNotificationBus
  100. void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
  101. //! EntityBus
  102. void OnEntityActivated(const AZ::EntityId& entityId) override;
  103. void UpdateSkyAtmosphereParams(SkyAtmosphereParams& params);
  104. TransformInterface* m_transformInterface = nullptr;
  105. SkyAtmosphereFeatureProcessorInterface* m_featureProcessorInterface = nullptr;
  106. SkyAtmosphereFeatureProcessorInterface::AtmosphereId m_atmosphereId;
  107. SkyAtmosphereComponentConfig m_configuration;
  108. SkyAtmosphereParams m_atmosphereParams;
  109. EntityId m_entityId;
  110. EntityId m_sunEntityId;
  111. };
  112. } // namespace AZ::Render