LightDelegateBase.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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/TransformBus.h>
  10. #include <Atom/Feature/CoreLights/PhotometricValue.h>
  11. #include <AtomLyIntegration/CommonFeatures/CoreLights/AreaLightComponentConfig.h>
  12. #include <LmbrCentral/Shape/SphereShapeComponentBus.h>
  13. #include <CoreLights/LightDelegateInterface.h>
  14. namespace AzFramework
  15. {
  16. class DebugDisplayRequests;
  17. }
  18. namespace AZ
  19. {
  20. class Color;
  21. class Transform;
  22. namespace Render
  23. {
  24. //! Delegate for managing light shape specific functionality in the AreaLightComponentController.
  25. template<typename FeatureProcessorType>
  26. class LightDelegateBase
  27. : public LightDelegateInterface
  28. , private LmbrCentral::ShapeComponentNotificationsBus::Handler
  29. , private TransformNotificationBus::Handler
  30. {
  31. public:
  32. LightDelegateBase(EntityId entityId, bool isVisible);
  33. virtual ~LightDelegateBase();
  34. void SetConfig(const AreaLightComponentConfig* config) override;
  35. // LightDelegateInterface overrides...
  36. void SetChroma(const Color& chroma) override;
  37. void SetIntensity(float intensity) override;
  38. float SetPhotometricUnit(PhotometricUnit unit) override;
  39. void SetAttenuationRadius(float radius) override;
  40. const PhotometricValue& GetPhotometricValue() const override { return m_photometricValue; }
  41. void SetLightEmitsBothDirections([[maybe_unused]] bool lightEmitsBothDirections) override {}
  42. void SetUseFastApproximation([[maybe_unused]] bool useFastApproximation) override {}
  43. void SetVisibility(bool visibility) override;
  44. void SetEnableShutters(bool enabled) override { m_shuttersEnabled = enabled; }
  45. void SetShutterAngles([[maybe_unused]]float innerAngleDegrees, [[maybe_unused]]float outerAngleDegrees) override {}
  46. void SetEnableShadow(bool enabled) override { m_shadowsEnabled = enabled; }
  47. void SetShadowBias([[maybe_unused]] float bias) override {}
  48. void SetShadowmapMaxSize([[maybe_unused]] ShadowmapSize size) override {}
  49. void SetShadowFilterMethod([[maybe_unused]] ShadowFilterMethod method) override {}
  50. void SetFilteringSampleCount([[maybe_unused]] uint32_t count) override {}
  51. void SetEsmExponent([[maybe_unused]] float esmExponent) override {}
  52. void SetNormalShadowBias([[maybe_unused]] float bias) override {}
  53. void SetShadowCachingMode([[maybe_unused]] AreaLightComponentConfig::ShadowCachingMode cachingMode) override {}
  54. void SetAffectsGI([[maybe_unused]] bool affectsGI) override {}
  55. void SetAffectsGIFactor([[maybe_unused]] float affectsGIFactor) override {}
  56. protected:
  57. void InitBase(EntityId entityId);
  58. // Trivial getters
  59. FeatureProcessorType* GetFeatureProcessor() const { return m_featureProcessor; }
  60. const AreaLightComponentConfig* GetConfig() const { return m_componentConfig; }
  61. typename FeatureProcessorType::LightHandle GetLightHandle() const { return m_lightHandle; }
  62. const Transform& GetTransform() const { return m_transform; }
  63. bool GetShuttersEnabled() { return m_shuttersEnabled; }
  64. bool GetShadowsEnabled() { return m_shadowsEnabled; }
  65. virtual void HandleShapeChanged() = 0;
  66. // ShapeComponentNotificationsBus::Handler overrides...
  67. void OnShapeChanged(ShapeChangeReasons changeReason) override;
  68. // TransformNotificationBus::Handler overrides ...
  69. void OnTransformChanged(const Transform& local, const Transform& world) override;
  70. LmbrCentral::ShapeComponentRequests* m_shapeBus = nullptr;
  71. private:
  72. // Computes overall effect transform, taking shape translation offsets into account if applicable
  73. AZ::Transform ComputeOverallTransform(const Transform& entityTransform);
  74. FeatureProcessorType* m_featureProcessor = nullptr;
  75. typename FeatureProcessorType::LightHandle m_lightHandle;
  76. const AreaLightComponentConfig* m_componentConfig = nullptr;
  77. Transform m_transform;
  78. PhotometricValue m_photometricValue;
  79. bool m_shuttersEnabled = false;
  80. bool m_shadowsEnabled = false;
  81. };
  82. } // namespace Render
  83. } // namespace AZ
  84. #include <CoreLights/LightDelegateBase.inl>