sandbox
Loading...
Searching...
No Matches
selection_filter.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_POST_SELECTION_FILTER_HPP_
3#define LIBSBX_POST_SELECTION_FILTER_HPP_
4
5#include <libsbx/core/profiler.hpp>
6
7#include <libsbx/scenes/scenes_module.hpp>
8
9#include <libsbx/post/filter.hpp>
10
11namespace sbx::post {
12
13class selection_filter final : public filter {
14
15 using base = filter;
16
17public:
18
19 selection_filter(const std::vector<graphics::attachment_description>& attachments, const std::filesystem::path& path, std::vector<std::pair<std::string, std::string>>&& attachment_names)
20 : base{attachments, path},
21 _push_handler{base::pipeline()},
22 _attachment_names{std::move(attachment_names)} { }
23
24 ~selection_filter() override = default;
25
26 auto render(graphics::command_buffer& command_buffer) -> void override {
27 EASY_BLOCK("selection_filter::render");
28 SBX_PROFILE_SCOPE("selection_filter::render");
29
30 auto& scenes_module = core::engine::get_module<scenes::scenes_module>();
31 auto& scene = scenes_module.active_scene();
32 auto& environment = scene.environment();
33 auto& graph = scene.graph();
34
35 auto& graphics_module = core::engine::get_module<graphics::graphics_module>();
36
37 auto& pipeline = base::pipeline();
38 auto& descriptor_handler = base::descriptor_handler();
39
40 pipeline.bind(command_buffer);
41
42 _push_handler.push("color", sbx::math::color{1.0, 0.86, 0.49, 1.0});
43 _push_handler.push("thickness", 0.5f);
44
45 descriptor_handler.push("scene", environment.uniform_handler());
46 // descriptor_handler.push("resolve_image", graphics_module.attachment(_image));
47 // descriptor_handler.push("object_id_image", graphics_module.attachment(_object_id_image));
48 // descriptor_handler.push("linear_depth_image", graphics_module.attachment(_linear_depth_image));
49
50 for (const auto& [name, attachment] : _attachment_names) {
51 descriptor_handler.push(name, graphics_module.attachment(attachment));
52 }
53
54 if (!descriptor_handler.update(pipeline)) {
55 return;
56 }
57
58 descriptor_handler.bind_descriptors(command_buffer);
59 _push_handler.bind(command_buffer);
60
61 command_buffer.draw(3, 1, 0, 0);
62 }
63
64private:
65
66 graphics::push_handler _push_handler;
67
68 std::vector<std::pair<std::string, std::string>> _attachment_names;
69
70 std::string _image;
71 std::string _object_id_image;
72 std::string _linear_depth_image;
73
74}; // class selection_filter
75
76} // namespace sbx::post
77
78#endif // LIBSBX_POST_SELECTION_FILTER_HPP_
Definition: command_buffer.hpp:15
Definition: push_handler.hpp:18
RGBA color value type.
Definition: color.hpp:48
Definition: filter.hpp:19
Definition: selection_filter.hpp:13