]> git.sesse.net Git - movit/blob - glow_effect.cpp
Parametrize BM_DeinterlaceEffect so that we have both grayscale and BGRA.
[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 namespace movit {
13
14 GlowEffect::GlowEffect()
15         : blur(new BlurEffect),
16           cutoff(new HighlightCutoffEffect),
17           mix(new MixEffect)
18 {
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));
23 }
24
25 void GlowEffect::rewrite_graph(EffectChain *graph, Node *self)
26 {
27         assert(self->incoming_links.size() == 1);
28         Node *input = self->incoming_links[0];
29
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);
38
39         self->disabled = true;
40 }
41
42 bool GlowEffect::set_float(const string &key, float value) {
43         if (key == "blurred_mix_amount") {
44                 return mix->set_float("strength_second", value);
45         }
46         if (key == "highlight_cutoff") {
47                 return cutoff->set_float("cutoff", value);
48         }
49         return blur->set_float(key, value);
50 }
51
52 HighlightCutoffEffect::HighlightCutoffEffect()
53         : cutoff(0.0f)
54 {
55         register_float("cutoff", &cutoff);
56 }
57
58 string HighlightCutoffEffect::output_fragment_shader()
59 {
60         return read_file("highlight_cutoff_effect.frag");
61 }
62
63 }  // namespace movit