AreaLightComponentController.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/EntityBus.h>
  10. #include <AzCore/Component/Component.h>
  11. #include <AzCore/Component/TransformBus.h>
  12. #include <AzCore/Math/Color.h>
  13. #include <AzFramework/Entity/EntityDebugDisplayBus.h>
  14. #include <AtomLyIntegration/CommonFeatures/CoreLights/AreaLightBus.h>
  15. #include <AtomLyIntegration/CommonFeatures/CoreLights/AreaLightComponentConfig.h>
  16. #include <CoreLights/LightDelegateInterface.h>
  17. namespace AZ
  18. {
  19. namespace Render
  20. {
  21. class AreaLightComponentController final
  22. : private AreaLightRequestBus::Handler
  23. {
  24. public:
  25. friend class EditorAreaLightComponent;
  26. AZ_TYPE_INFO(AZ::Render::AreaLightComponentController, "{C185C0F7-0923-4EF7-94F7-B41D60FE535B}");
  27. static void Reflect(AZ::ReflectContext* context);
  28. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  29. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  30. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  31. AreaLightComponentController() = default;
  32. AreaLightComponentController(const AreaLightComponentConfig& config);
  33. void Activate(EntityId entityId);
  34. void Deactivate();
  35. void SetConfiguration(const AreaLightComponentConfig& config);
  36. const AreaLightComponentConfig& GetConfiguration() const;
  37. //! Used by the editor to control visibility - the controller must remain active while invisible to handle light unit conversions.
  38. void SetVisibiliy(bool isVisible);
  39. private:
  40. AZ_DISABLE_COPY(AreaLightComponentController);
  41. // AreaLightRequestBus::Handler overrides ...
  42. const Color& GetColor() const override;
  43. void SetColor(const Color& color) override;
  44. bool GetLightEmitsBothDirections() const override;
  45. void SetLightEmitsBothDirections(bool value) override;
  46. bool GetUseFastApproximation() const override;
  47. void SetUseFastApproximation(bool useFastApproximation) override;
  48. PhotometricUnit GetIntensityMode() const override;
  49. float GetIntensity() const override;
  50. void SetIntensityAndMode(float intensity, PhotometricUnit intensityMode) override;
  51. void SetIntensity(float intensity, PhotometricUnit intensityMode) override;
  52. void SetIntensity(float intensity) override;
  53. float GetAttenuationRadius() const override;
  54. void SetAttenuationRadius(float radius) override;
  55. void SetAttenuationRadiusMode(LightAttenuationRadiusMode attenuationRadiusMode) override;
  56. void ConvertToIntensityMode(PhotometricUnit intensityMode) override;
  57. float GetSurfaceArea() const override;
  58. bool GetEnableShutters() const override;
  59. void SetEnableShutters(bool enabled) override;
  60. float GetInnerShutterAngle() const override;
  61. void SetInnerShutterAngle(float degrees) override;
  62. float GetOuterShutterAngle() const override;
  63. void SetOuterShutterAngle(float degrees) override;
  64. bool GetEnableShadow() const override;
  65. void SetEnableShadow(bool enabled) override;
  66. float GetShadowBias() const override;
  67. void SetShadowBias(float bias) override;
  68. ShadowmapSize GetShadowmapMaxSize() const override;
  69. void SetShadowmapMaxSize(ShadowmapSize size) override;
  70. ShadowFilterMethod GetShadowFilterMethod() const override;
  71. void SetShadowFilterMethod(ShadowFilterMethod method) override;
  72. uint32_t GetFilteringSampleCount() const override;
  73. void SetFilteringSampleCount(uint32_t count) override;
  74. float GetEsmExponent() const override;
  75. void SetEsmExponent(float exponent) override;
  76. float GetNormalShadowBias() const override;
  77. void SetNormalShadowBias(float bias) override;
  78. AreaLightComponentConfig::ShadowCachingMode GetShadowCachingMode() const override;
  79. void SetShadowCachingMode(AreaLightComponentConfig::ShadowCachingMode cachingMode) override;
  80. bool GetAffectsGI() const override;
  81. void SetAffectsGI(bool affectsGI) const override;
  82. float GetAffectsGIFactor() const override;
  83. void SetAffectsGIFactor(float affectsGIFactor) const override;
  84. AZ::Aabb GetLocalVisualizationBounds() const override;
  85. void HandleDisplayEntityViewport(
  86. const AzFramework::ViewportInfo& viewportInfo,
  87. AzFramework::DebugDisplayRequests& debugDisplay,
  88. bool isSelected);
  89. void VerifyLightTypeAndShapeComponent();
  90. void ConfigurationChanged();
  91. void IntensityChanged();
  92. void ChromaChanged();
  93. void AttenuationRadiusChanged();
  94. void ShuttersChanged();
  95. void ShadowsChanged();
  96. //! Handles calculating the attenuation radius when LightAttenuationRadiusMode is auto
  97. void AutoCalculateAttenuationRadius();
  98. //! Handles creating the light shape delegate. Separate function to allow for early returns once the correct shape interface is found.
  99. void CreateLightShapeDelegate();
  100. AZStd::unique_ptr<LightDelegateInterface> m_lightShapeDelegate;
  101. AreaLightComponentConfig m_configuration;
  102. EntityId m_entityId;
  103. bool m_isVisible = true;
  104. };
  105. } // namespace Render
  106. } // AZ namespace