4 #include "blur_effect.h"
5 #include "effect_chain.h"
6 #include "glow_effect.h"
7 #include "mix_effect.h"
12 GlowEffect::GlowEffect()
13 : blur(new BlurEffect),
14 cutoff(new HighlightCutoffEffect),
17 CHECK(blur->set_float("radius", 20.0f));
18 CHECK(mix->set_float("strength_first", 1.0f));
19 CHECK(mix->set_float("strength_second", 1.0f));
20 CHECK(cutoff->set_float("cutoff", 0.2f));
23 void GlowEffect::rewrite_graph(EffectChain *graph, Node *self)
25 assert(self->incoming_links.size() == 1);
26 Node *input = self->incoming_links[0];
28 Node *blur_node = graph->add_node(blur);
29 Node *mix_node = graph->add_node(mix);
30 Node *cutoff_node = graph->add_node(cutoff);
31 graph->replace_receiver(self, mix_node);
32 graph->connect_nodes(input, cutoff_node);
33 graph->connect_nodes(cutoff_node, blur_node);
34 graph->connect_nodes(blur_node, mix_node);
35 graph->replace_sender(self, mix_node);
37 self->disabled = true;
40 bool GlowEffect::set_float(const string &key, float value) {
41 if (key == "blurred_mix_amount") {
42 return mix->set_float("strength_second", value);
44 if (key == "highlight_cutoff") {
45 return cutoff->set_float("cutoff", value);
47 return blur->set_float(key, value);
50 HighlightCutoffEffect::HighlightCutoffEffect()
53 register_float("cutoff", &cutoff);
56 string HighlightCutoffEffect::output_fragment_shader()
58 return read_file("highlight_cutoff_effect.frag");