sandbox
Loading...
Searching...
No Matches
bloom_filter.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_POST_FILTERS_BLOOM_FILTER_HPP_
3#define LIBSBX_POST_FILTERS_BLOOM_FILTER_HPP_
4
5#include <libsbx/utility/enum.hpp>
6
7#include <libsbx/math/vector2.hpp>
8
9#include <libsbx/post/filter.hpp>
10
11namespace sbx::post {
12
13
14class bloom_filter final : public filter {
15
16 using base = filter;
17
18public:
19
20 bloom_filter(const std::vector<graphics::attachment_description>& attachments, const std::filesystem::path& path, const std::string& attachment_name, std::float_t threshold, std::float_t intensity)
21 : base{attachments, path, base::default_pipeline_definition},
22 _push_handler{base::pipeline()},
23 _attachment_name{attachment_name},
24 _threshold{threshold},
25 _intensity{intensity} { }
26
27 ~bloom_filter() override = default;
28
29 auto render(graphics::command_buffer& command_buffer) -> void override {
30 EASY_BLOCK("bloom_filter::render");
31
32 auto& pipeline = base::pipeline();
33 auto& descriptor_handler = base::descriptor_handler();
34
35 auto& graphics_module = core::engine::get_module<graphics::graphics_module>();
36
37 pipeline.bind(command_buffer);
38
39 // _push_handler.push("threshold", 1.0f);
40 // _push_handler.push("intensity", 1.0f);
41 // _push_handler.push("radius", 10.0f);
42
43 descriptor_handler.push("image", graphics_module.attachment(_attachment_name));
44
45 if (!descriptor_handler.update(pipeline)) {
46 return;
47 }
48
49 descriptor_handler.bind_descriptors(command_buffer);
50 // _push_handler.bind(command_buffer);
51
52 command_buffer.draw(3, 1, 0, 0);
53 }
54
55private:
56
57 graphics::push_handler _push_handler;
58
59 std::string _attachment_name;
60 math::vector2 _threshold;
61 math::vector2 _intensity;
62
63}; // class bloom_filter
64
65} // namespace sbx::post
66
67#endif // LIBSBX_POST_FILTERS_BLOOM_FILTER_HPP_
Definition: command_buffer.hpp:15
Definition: push_handler.hpp:18
A vector in two-dimensional space.
Definition: vector2.hpp:28
Definition: bloom_filter.hpp:14
Definition: filter.hpp:19