sandbox
Loading...
Searching...
No Matches
skinned_mesh_shadow_subrenderer.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_ANIMATIONS_SKINNED_MESH_SHADOW_SUBRENDERER_HPP_
3#define LIBSBX_ANIMATIONS_SKINNED_MESH_SHADOW_SUBRENDERER_HPP_
4
5#include <filesystem>
6#include <unordered_map>
7#include <array>
8
9#include <vulkan/vulkan.h>
10
11#include <libsbx/core/engine.hpp>
12
13#include <libsbx/memory/observer_ptr.hpp>
14
15#include <libsbx/graphics/subrenderer.hpp>
16#include <libsbx/graphics/graphics_module.hpp>
17#include <libsbx/graphics/pipeline/graphics_pipeline.hpp>
18#include <libsbx/graphics/buffers/push_handler.hpp>
19#include <libsbx/graphics/descriptor/descriptor_handler.hpp>
20
21#include <libsbx/assets/assets_module.hpp>
22#include <libsbx/scenes/scenes_module.hpp>
23
24#include <libsbx/models/models.hpp>
25#include <libsbx/models/material_draw_list.hpp>
26
27#include <libsbx/animations/skinned_mesh_material_draw_list.hpp>
28#include <libsbx/animations/skinning_task.hpp>
29
30namespace sbx::animations {
31
33
34 inline static const auto pipeline_definition = graphics::pipeline_definition{
35 .depth = graphics::depth::read_write,
36 .uses_transparency = false,
37 .rasterization_state = graphics::rasterization_state{
38 .polygon_mode = graphics::polygon_mode::fill,
39 .cull_mode = graphics::cull_mode::none,
40 .front_face = graphics::front_face::counter_clockwise
41 }
42 };
43
44 inline static constexpr auto default_pipeline_path = std::string_view{"engine://shaders/shadow"};
45
46public:
47
48 skinned_mesh_shadow_subrenderer(const std::vector<graphics::attachment_description>& attachments, const std::filesystem::path& base_pipeline = default_pipeline_path);
49
51
52 auto render(graphics::command_buffer& command_buffer) -> void override;
53
54private:
55
56 struct pipeline_data {
57
59 graphics::push_handler push_handler;
60
61 pipeline_data(const graphics::graphics_pipeline_handle& handle);
62
63 }; // struct pipeline_data
64
65 struct descriptor_data {
66
67 graphics::descriptor_handler scene_descriptor_handler;
68 graphics::descriptor_handler sampler_descriptor_handler;
69 graphics::descriptor_handler image_descriptor_handler;
70
71 descriptor_data(const graphics::graphics_pipeline_handle& handle);
72
73 }; // struct descriptor_data
74
75 auto _get_or_create_pipeline(const models::material_key& key) -> pipeline_data&;
76
77 auto _get_or_create_descriptor_data(const graphics::graphics_pipeline_handle& handle) -> descriptor_data&;
78
79 inline static const auto _entry_point = std::array<std::string, 3u>{
80 "opaque_main", // alpha_mode::opaque
81 "mask_main", // alpha_mode::mask
82 "blend_main" // alpha_mode::blend
83 };
84
85 std::vector<graphics::attachment_description> _attachments;
86 std::filesystem::path _base_pipeline;
87
88 inline static std::unordered_map<models::material_key, pipeline_data, models::material_key_hash> _pipeline_cache{};
89
90 std::unordered_map<graphics::graphics_pipeline_handle, descriptor_data> _descriptor_cache{};
91
92}; // class shadow_subrenderer
93
94} // namespace sbx::animations
95
96#endif // LIBSBX_ANIMATIONS_SKINNED_MESH_SHADOW_SUBRENDERER_HPP_
Definition: skinned_mesh_shadow_subrenderer.hpp:32
Definition: command_buffer.hpp:15
Definition: descriptor_handler.hpp:26
Definition: push_handler.hpp:18
Definition: resource_storage.hpp:18
Definition: subrenderer.hpp:14
Definition: graphics_pipeline.hpp:106
Definition: graphics_pipeline.hpp:67
Definition: material.hpp:87