1 | #pragma once |
---|---|
2 | #include "taichi/ui/common/scene_base.h" |
3 | |
4 | namespace taichi::ui { |
5 | |
6 | namespace vulkan { |
7 | |
8 | class Scene final : public SceneBase { |
9 | public: |
10 | friend class Renderer; |
11 | friend class Particles; |
12 | friend class Mesh; |
13 | friend class SceneLines; |
14 | |
15 | private: |
16 | struct SceneUniformBuffer { |
17 | alignas(16) glm::vec3 camera_pos; |
18 | alignas(16) glm::mat4 view; |
19 | alignas(16) glm::mat4 projection; |
20 | alignas(16) glm::vec3 ambient_light; |
21 | int point_light_count; |
22 | }; |
23 | SceneUniformBuffer current_ubo_; |
24 | |
25 | void update_ubo(float aspect_ratio) { |
26 | current_ubo_.camera_pos = camera_.position; |
27 | current_ubo_.view = camera_.get_view_matrix(); |
28 | current_ubo_.projection = camera_.get_projection_matrix(aspect_ratio); |
29 | current_ubo_.point_light_count = point_lights_.size(); |
30 | |
31 | current_ubo_.ambient_light = ambient_light_color_; |
32 | } |
33 | }; |
34 | |
35 | } // namespace vulkan |
36 | |
37 | } // namespace taichi::ui |
38 |