]> git.sesse.net Git - movit/blob - glow_effect.cpp
Move to 'using namespace std;' in all .cpp files.
[movit] / glow_effect.cpp
1 #include <assert.h>
2 #include <vector>
3
4 #include "blur_effect.h"
5 #include "effect_chain.h"
6 #include "glow_effect.h"
7 #include "mix_effect.h"
8 #include "util.h"
9
10 using namespace std;
11
12 GlowEffect::GlowEffect()
13         : blur(new BlurEffect),
14           cutoff(new HighlightCutoffEffect),
15           mix(new MixEffect)
16 {
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));
21 }
22
23 void GlowEffect::rewrite_graph(EffectChain *graph, Node *self)
24 {
25         assert(self->incoming_links.size() == 1);
26         Node *input = self->incoming_links[0];
27
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);
36
37         self->disabled = true;
38 }
39
40 bool GlowEffect::set_float(const string &key, float value) {
41         if (key == "blurred_mix_amount") {
42                 return mix->set_float("strength_second", value);
43         }
44         if (key == "highlight_cutoff") {
45                 return cutoff->set_float("cutoff", value);
46         }
47         return blur->set_float(key, value);
48 }
49
50 HighlightCutoffEffect::HighlightCutoffEffect()
51         : cutoff(0.0f)
52 {
53         register_float("cutoff", &cutoff);
54 }
55
56 string HighlightCutoffEffect::output_fragment_shader()
57 {
58         return read_file("highlight_cutoff_effect.frag");
59 }