4 #include "blur_effect.h"
5 #include "effect_chain.h"
6 #include "glow_effect.h"
7 #include "mix_effect.h"
14 GlowEffect::GlowEffect()
15 : blur(new BlurEffect),
16 cutoff(new HighlightCutoffEffect),
19 CHECK(blur->set_float("radius", 20.0f));
20 CHECK(mix->set_float("strength_first", 1.0f));
21 CHECK(mix->set_float("strength_second", 1.0f));
22 CHECK(cutoff->set_float("cutoff", 0.2f));
25 void GlowEffect::rewrite_graph(EffectChain *graph, Node *self)
27 assert(self->incoming_links.size() == 1);
28 Node *input = self->incoming_links[0];
30 Node *blur_node = graph->add_node(blur);
31 Node *mix_node = graph->add_node(mix);
32 Node *cutoff_node = graph->add_node(cutoff);
33 graph->replace_receiver(self, mix_node);
34 graph->connect_nodes(input, cutoff_node);
35 graph->connect_nodes(cutoff_node, blur_node);
36 graph->connect_nodes(blur_node, mix_node);
37 graph->replace_sender(self, mix_node);
39 self->disabled = true;
42 bool GlowEffect::set_float(const string &key, float value) {
43 if (key == "blurred_mix_amount") {
44 return mix->set_float("strength_second", value);
46 if (key == "highlight_cutoff") {
47 return cutoff->set_float("cutoff", value);
49 return blur->set_float(key, value);
52 HighlightCutoffEffect::HighlightCutoffEffect()
55 register_float("cutoff", &cutoff);
58 string HighlightCutoffEffect::output_fragment_shader()
60 return read_file("highlight_cutoff_effect.frag");