4 #include "glow_effect.h"
5 #include "blur_effect.h"
6 #include "mix_effect.h"
7 #include "effect_chain.h"
10 GlowEffect::GlowEffect()
11 : blur(new BlurEffect),
12 cutoff(new HighlightCutoffEffect),
15 CHECK(blur->set_float("radius", 20.0f));
16 CHECK(mix->set_float("strength_first", 1.0f));
17 CHECK(mix->set_float("strength_second", 1.0f));
18 CHECK(cutoff->set_float("cutoff", 0.2f));
21 void GlowEffect::rewrite_graph(EffectChain *graph, Node *self)
23 assert(self->incoming_links.size() == 1);
24 Node *input = self->incoming_links[0];
26 Node *blur_node = graph->add_node(blur);
27 Node *mix_node = graph->add_node(mix);
28 Node *cutoff_node = graph->add_node(cutoff);
29 graph->replace_receiver(self, mix_node);
30 graph->connect_nodes(input, cutoff_node);
31 graph->connect_nodes(cutoff_node, blur_node);
32 graph->connect_nodes(blur_node, mix_node);
33 graph->replace_sender(self, mix_node);
35 self->disabled = true;
38 bool GlowEffect::set_float(const std::string &key, float value) {
39 if (key == "blurred_mix_amount") {
40 return mix->set_float("strength_second", value);
42 if (key == "highlight_cutoff") {
43 return cutoff->set_float("cutoff", value);
45 return blur->set_float(key, value);
48 HighlightCutoffEffect::HighlightCutoffEffect()
51 register_float("cutoff", &cutoff);
54 std::string HighlightCutoffEffect::output_fragment_shader()
56 return read_file("highlight_cutoff_effect.frag");