SkyAtmosphereFeatureProcessor.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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/SkyAtmosphere/SkyAtmosphereFeatureProcessorInterface.h>
  10. #include <Atom/Feature/Utils/SparseVector.h>
  11. namespace AZ::Render
  12. {
  13. class SkyAtmosphereParentPass;
  14. //! This feature processor manages drawing sky atmospheres.
  15. //! Use CreateAtmosphere() to create a new atmosphere
  16. class SkyAtmosphereFeatureProcessor final
  17. : public SkyAtmosphereFeatureProcessorInterface
  18. {
  19. public:
  20. AZ_CLASS_ALLOCATOR(SkyAtmosphereFeatureProcessor, AZ::SystemAllocator)
  21. AZ_RTTI(AZ::Render::SkyAtmosphereFeatureProcessor, "{FB3155E9-BA3C-487B-B251-EB4BF3465E02}", AZ::Render::SkyAtmosphereFeatureProcessorInterface);
  22. static void Reflect(AZ::ReflectContext* context);
  23. SkyAtmosphereFeatureProcessor() = default;
  24. virtual ~SkyAtmosphereFeatureProcessor() = default;
  25. //! FeatureProcessor
  26. void Activate() override;
  27. void Deactivate() override;
  28. void AddRenderPasses(RPI::RenderPipeline* renderPipeline) override;
  29. void Render(const RenderPacket& packet) override;
  30. //! SkyAtmosphereFeatureProcessorInterface
  31. AtmosphereId CreateAtmosphere() override;
  32. void ReleaseAtmosphere(AtmosphereId id) override;
  33. void SetAtmosphereParams(AtmosphereId id, const SkyAtmosphereParams& params) override;
  34. void SetAtmosphereEnabled(AtmosphereId id, bool enabled) override;
  35. bool GetAtmosphereEnabled(AtmosphereId id) override;
  36. private:
  37. //! RPI::SceneNotificationBus::Handler
  38. void OnRenderPipelineChanged(AZ::RPI::RenderPipeline* pipeline, RPI::SceneNotification::RenderPipelineChangeType changeType) override;
  39. void InitializeAtmosphere(AtmosphereId id);
  40. void UpdateBackgroundClearColor();
  41. bool HasValidAtmosphere();
  42. struct SkyAtmosphere
  43. {
  44. AtmosphereId m_id;
  45. SkyAtmosphereParams m_params;
  46. bool m_passNeedsUpdate = false;
  47. bool m_enabled = false;
  48. };
  49. SparseVector<SkyAtmosphere> m_atmospheres;
  50. AZStd::vector<SkyAtmosphereParentPass*> m_skyAtmosphereParentPasses;
  51. };
  52. }