SplashScreenPass.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/Memory/SystemAllocator.h>
  10. #include <AzCore/Component/TickBus.h>
  11. #include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
  12. #include <Atom/RPI.Reflect/Pass/PassDescriptor.h>
  13. #include <Atom/Feature/SplashScreen/SplashScreenSettings.h>
  14. namespace AZ::Render
  15. {
  16. class SplashScreenPass
  17. : public AZ::RPI::FullscreenTrianglePass
  18. , public AZ::TickBus::Handler
  19. {
  20. AZ_RPI_PASS(SplashScreenPass);
  21. public:
  22. AZ_RTTI(AZ::Render::SplashScreenPass, "{B12F4E30-94ED-4F69-A17D-85C65853ACD9}", AZ::RPI::FullscreenTrianglePass);
  23. AZ_CLASS_ALLOCATOR(AZ::Render::SplashScreenPass, AZ::SystemAllocator, 0);
  24. virtual ~SplashScreenPass();
  25. static AZ::RPI::Ptr<SplashScreenPass> Create(const AZ::RPI::PassDescriptor& descriptor);
  26. //! TickBus overrides...
  27. //! Update tick for animation in the splash screen pass.
  28. //! Due to deltaTime scalability, it is actually using an abosulte time stamp for delta time.
  29. void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
  30. //! Scope producer functions...
  31. //! Set up srg indices for images and shader data.
  32. void CompileResources(const AZ::RHI::FrameGraphCompileContext& context) override;
  33. private:
  34. SplashScreenPass(const AZ::RPI::PassDescriptor& descriptor);
  35. void Clear();
  36. // Pass behavior overrides...
  37. void InitializeInternal() override;
  38. void FrameBeginInternal(FramePrepareParams params) override;
  39. void FrameEndInternal() override;
  40. //! Flag to begin timing.
  41. bool m_beginTimer = false;
  42. //! The time that the splash screen will last. Will be set from splash_screen.setreg.
  43. float m_durationSeconds = 10.0f;
  44. //! Time stamp in seconds, used to calculate unscaled delta time.
  45. float m_lastRealTimeStamp;
  46. // Data struct passed to the shader.
  47. struct SplashScreenParams
  48. {
  49. float m_fadingFactor;
  50. };
  51. //! Shader connections
  52. AZ::Data::Instance<AZ::RPI::StreamingImage> m_splashScreenImage;
  53. AZ::RHI::ShaderInputNameIndex m_splashScreenImageIndex = "m_splashScreenImage";
  54. SplashScreenParams m_splashScreenParams;
  55. AZ::RHI::ShaderInputNameIndex m_splashScreenParamsIndex = "m_splashScreenParams";
  56. //! Splash screen settings read from setreg
  57. SplashScreenSettings m_settings;
  58. };
  59. }