LightDelegateInterface.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 <Atom/Feature/CoreLights/PhotometricValue.h>
  10. #include <Atom/Feature/CoreLights/ShadowConstants.h>
  11. #include <AtomCore/Instance/Instance.h>
  12. #include <AzCore/Component/TransformBus.h>
  13. namespace AzFramework
  14. {
  15. class DebugDisplayRequests;
  16. }
  17. namespace AZ
  18. {
  19. class Color;
  20. class Transform;
  21. class Aabb;
  22. namespace RPI
  23. {
  24. class Image;
  25. }
  26. namespace Render
  27. {
  28. //! Delegate for managing light shape specific functionality in the AreaLightComponentController.
  29. class LightDelegateInterface
  30. {
  31. public:
  32. virtual ~LightDelegateInterface() = default;
  33. //! Sets the area light component config so delegates don't have to cache the same data locally.
  34. virtual void SetConfig(const AreaLightComponentConfig* config) = 0;
  35. //! Sets the color of the light independent of light intensity. The color is a mask on the total light intensity.
  36. virtual void SetChroma(const Color& chroma) = 0;
  37. //! Sets the light intensity.
  38. virtual void SetIntensity(float intensity) = 0;
  39. //! Sets the light unit, and returns the converted light intensity.
  40. virtual float SetPhotometricUnit(PhotometricUnit unit) = 0;
  41. //! Sets the maximum distance from any part of the surface of the area light at which this light will have an effect.
  42. virtual void SetAttenuationRadius(float radius) = 0;
  43. //! Gets the light intensity.
  44. virtual const PhotometricValue& GetPhotometricValue() const = 0;
  45. //! Gets the surface area of the shape.
  46. virtual float GetSurfaceArea() const = 0;
  47. //! Returns the number of steradians covered by this light type.
  48. virtual float GetEffectiveSolidAngle() const = 0;
  49. //! Sets if this shape is double-sided (only applicable for 2d shapes).
  50. virtual void SetLightEmitsBothDirections([[maybe_unused]] bool lightEmitsBothDirections) = 0;
  51. //! Sets if this light uses linearly transformed cosines (false) or a faster approximation (true). Only applicable for shapes
  52. //! that support LTC.
  53. virtual void SetUseFastApproximation([[maybe_unused]] bool useFastApproximation) = 0;
  54. //! Calculates the attenuation radius for this light type based on a threshold value.
  55. virtual float CalculateAttenuationRadius(float lightThreshold) const = 0;
  56. //! Handle any additional debug display drawing for beyond what the shape already provides.
  57. virtual void DrawDebugDisplay(
  58. const Transform& transform, const Color& color, AzFramework::DebugDisplayRequests& debugDisplay, bool isSelected) const = 0;
  59. //! Turns the visibility of this light on/off.
  60. virtual void SetVisibility(bool visibility) = 0;
  61. // gobo
  62. virtual void SetGoboTexture(AZ::Data::Instance<AZ::RPI::Image> goboTexture) = 0;
  63. // Shutters
  64. // Sets if the light should be restricted to shutter angles.
  65. virtual void SetEnableShutters(bool enabled) = 0;
  66. // Sets the inner and outer angles of the shutters in degrees for where the light
  67. // beam starts to attenuate (inner) to where it is completely occluded (outer).
  68. virtual void SetShutterAngles(float innerAngleDegrees, float outerAngleDegrees) = 0;
  69. // Shadows
  70. //! Sets if shadows should be enabled.
  71. virtual void SetEnableShadow(bool enabled) = 0;
  72. //! Sets the shadow bias.
  73. virtual void SetShadowBias(float bias) = 0;
  74. //! Sets the maximum resolution of the shadow map.
  75. virtual void SetShadowmapMaxSize(ShadowmapSize size) = 0;
  76. //! Sets the filter method for the shadow.
  77. virtual void SetShadowFilterMethod(ShadowFilterMethod method) = 0;
  78. //! Sets the sample count for filtering of the shadow boundary, max 64.
  79. virtual void SetFilteringSampleCount(uint32_t count) = 0;
  80. //! Sets the Esm exponent to use. Higher values produce a steeper falloff between light and shadow.
  81. virtual void SetEsmExponent(float exponent) = 0;
  82. //! Sets the normal bias. Reduces acne by biasing the shadowmap lookup along the geometric normal.
  83. virtual void SetNormalShadowBias(float bias) = 0;
  84. //! Sets the current shadow caching mode. Cached shadows use persistent textures and only update
  85. //! when they detect a change. Regular shadows use transient textures but re-render every frame.
  86. virtual void SetShadowCachingMode(AreaLightComponentConfig::ShadowCachingMode cachingMode) = 0;
  87. // Global Illumination
  88. //! Sets if the light should affect diffuse global illumination.
  89. virtual void SetAffectsGI(bool affectsGI) = 0;
  90. //! Sets the multiplier on the contribution to diffuse global illumination.
  91. virtual void SetAffectsGIFactor(float affectsGIFactor) = 0;
  92. //! Set the lighting channel mask
  93. virtual void SetLightingChannelMask(uint32_t lightingChannelMask) = 0;
  94. // Debug Visualization
  95. //! Returns the Aabb for the debug visualization of the light.
  96. virtual Aabb GetLocalVisualizationBounds() const = 0;
  97. };
  98. } // namespace Render
  99. } // namespace AZ