#pragma once #include "rhi.h" #include "scene/scene_types.h" #include #include namespace Donut { struct GeodesicView { glm::vec3 position, right, up, forward; float tan_half_fov = 1.0f; float aspect = 16.0f / 9.0f; bool moving = false; float time = 0.0f; }; class BlackHoleRenderer { public: static constexpr int GEO_LO_W = 480, GEO_LO_H = 270; static constexpr int GEO_HI_W = 960, GEO_HI_H = 540; auto init(RHI::Device& device) -> bool; auto render_geodesic(RHI::CommandList& cmd, const GeodesicView& view, const BlackHoleParams& params, const std::vector& objects, RHI::Texture* cubemap) -> void; auto blit(RHI::CommandList& cmd, int fb_width, int fb_height) -> void; auto render_export(RHI::CommandList& cmd, RHI::RenderTarget* target, const GeodesicView& view, const BlackHoleParams& params, const std::vector& objects, RHI::Texture* cubemap, int channel, bool raw) -> void; private: auto fill_uniforms(const GeodesicView& view, const BlackHoleParams& params, const std::vector& objects, int channel, bool raw) -> void; auto draw_geodesic(RHI::CommandList& cmd, RHI::RenderTarget* target, RHI::Texture* cubemap, RHI::Pipeline* pipeline) -> void; RHI::Device* m_device = nullptr; Ref m_geo_pipeline; Ref m_geo_pipeline_hdr; Ref m_geo_lo; Ref m_geo_hi; Ref m_quad_vb; Ref m_cam_ubo; Ref m_disk_ubo; Ref m_obj_ubo; Ref m_sim_ubo; Ref m_present_pipeline; RHI::RenderTarget* m_last_target = nullptr; }; }