RayTracingVertexFormatExampleComponent.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/Debug/RayTracingDebugFeatureProcessorInterface.h>
  10. #include <Atom/Feature/RayTracing/RayTracingFeatureProcessorInterface.h>
  11. #include <AzCore/Component/TickBus.h>
  12. #include <CommonSampleComponentBase.h>
  13. #include <Utils/ImGuiAssetBrowser.h>
  14. #include <Utils/ImGuiSidebar.h>
  15. namespace AtomSampleViewer
  16. {
  17. class RayTracingVertexFormatExampleComponent final
  18. : public CommonSampleComponentBase
  19. , public AZ::TickBus::Handler
  20. {
  21. public:
  22. AZ_COMPONENT(RayTracingVertexFormatExampleComponent, "{5F0067E0-DBFD-45AB-89D2-36FD3D45BCBB}", AZ::Component);
  23. AZ_DISABLE_COPY_MOVE(RayTracingVertexFormatExampleComponent);
  24. RayTracingVertexFormatExampleComponent() = default;
  25. static void Reflect(AZ::ReflectContext* context);
  26. protected:
  27. // AZ::Component overrides
  28. void Activate() override;
  29. void Deactivate() override;
  30. private:
  31. // AZ::TickBus overrides
  32. void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
  33. void DrawSidebar();
  34. void ModelChanged();
  35. AZ::RPI::Ptr<AZ::RPI::Buffer> ConvertVertexBuffer(
  36. AZStd::span<const uint8_t> sourceBufferData,
  37. const AZ::RHI::BufferViewDescriptor& sourceBufferDescriptor,
  38. AZ::RHI::VertexFormat targetFormat,
  39. int sourceComponentCountOverride = 0);
  40. AZ::RPI::Ptr<AZ::RPI::Buffer> ConvertIndexBuffer(
  41. AZStd::span<const uint8_t> sourceBufferData,
  42. const AZ::RHI::BufferViewDescriptor& sourceBufferDescriptor,
  43. AZ::RHI::IndexFormat targetFormat);
  44. AZ::Render::RayTracingFeatureProcessorInterface& GetRayTracingFeatureProcessor();
  45. AZ::Render::RayTracingDebugFeatureProcessorInterface& GetRayTracingDebugFeatureProcessor();
  46. ImGuiSidebar m_imguiSidebar;
  47. ImGuiAssetBrowser m_modelBrowser{ "@user@/RayTracingVertexFormatExampleComponent/model_browser.xml" };
  48. AZ::Data::Asset<AZ::RPI::ModelAsset> m_currentModel;
  49. AZ::Uuid m_rayTracingUuid{ "85E1BC6E-AE09-4EF1-87B7-A0F237BDABCC" };
  50. AZ::Render::RayTracingFeatureProcessorInterface* m_rayTracingFeatureProcessor{ nullptr };
  51. AZ::Render::RayTracingDebugFeatureProcessorInterface* m_rayTracingDebugFeatureProcessor{ nullptr };
  52. AZ::Render::RayTracingDebugViewMode m_debugViewMode{ AZ::Render::RayTracingDebugViewMode::PrimitiveIndex };
  53. AZ::RHI::IndexFormat m_indexFormat{ AZ::RHI::IndexFormat::Uint32 };
  54. AZ::RHI::VertexFormat m_positionFormat{ AZ::RHI::VertexFormat::R32G32B32_FLOAT };
  55. AZ::RHI::VertexFormat m_normalFormat{ AZ::RHI::VertexFormat::R32G32B32_FLOAT };
  56. AZ::RHI::VertexFormat m_uvFormat{ AZ::RHI::VertexFormat::R32G32_FLOAT };
  57. AZ::RHI::VertexFormat m_tangentFormat{ AZ::RHI::VertexFormat::R32G32B32A32_FLOAT };
  58. AZ::RHI::VertexFormat m_bitangentFormat{ AZ::RHI::VertexFormat::R32G32B32_FLOAT };
  59. };
  60. } // namespace AtomSampleViewer