SSRExampleComponent.h 2.4 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 <CommonSampleComponentBase.h>
  10. #include <AzCore/Component/TickBus.h>
  11. #include <Atom/Feature/Mesh/MeshFeatureProcessorInterface.h>
  12. #include <Atom/Feature/ImGui/ImGuiUtils.h>
  13. #include <Utils/ImGuiSidebar.h>
  14. #include <Utils/Utils.h>
  15. namespace AtomSampleViewer
  16. {
  17. //!
  18. //! This component creates a simple scene that tests Screen Space Reflections.
  19. //!
  20. class SSRExampleComponent final
  21. : public CommonSampleComponentBase
  22. , public AZ::TickBus::Handler
  23. {
  24. public:
  25. AZ_COMPONENT(AtomSampleViewer::SSRExampleComponent, "{B537E911-48B7-4883-A0F1-4CAAB968BAD4}", CommonSampleComponentBase);
  26. static void Reflect(AZ::ReflectContext* context);
  27. SSRExampleComponent() = default;
  28. ~SSRExampleComponent() override = default;
  29. void Activate() override;
  30. void Deactivate() override;
  31. private:
  32. AZ_DISABLE_COPY_MOVE(SSRExampleComponent);
  33. void CreateModels();
  34. void CreateGroundPlane();
  35. // AZ::TickBus::Handler
  36. void OnTick(float deltaTime, AZ::ScriptTimePoint timePoint) override;
  37. void OnModelReady(AZ::Data::Instance<AZ::RPI::Model> model);
  38. void DrawSidebar();
  39. void UpdateSSROptions();
  40. // meshes
  41. AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_statueMeshHandle;
  42. AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_boxMeshHandle;
  43. AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_shaderBallMeshHandle;
  44. AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_groundMeshHandle;
  45. AZ::Data::Asset<AZ::RPI::MaterialAsset> m_groundMaterialAsset;
  46. // ground plane material setting
  47. int m_groundPlaneMaterial = 0;
  48. // IBL and skybox
  49. Utils::DefaultIBL m_defaultIbl;
  50. AZ::Data::Asset<AZ::RPI::StreamingImageAsset> m_skyboxImageAsset;
  51. ImGuiSidebar m_imguiSidebar;
  52. bool m_enableSSR = true;
  53. bool m_rayTracing = false;
  54. bool m_rayTraceFallbackData = true;
  55. bool m_resetCamera = true;
  56. float m_originalFarClipDistance = 0.0f;
  57. float m_maxDepthThreshold = 0.4f;
  58. float m_temporalFilteringStrength = 0.25f;
  59. };
  60. } // namespace AtomSampleViewer