]> git.sesse.net Git - movit/blob - diffusion_effect.cpp
Change to using GLEW everywhere.
[movit] / diffusion_effect.cpp
1 #include <math.h>
2 #include <assert.h>
3
4 #include "diffusion_effect.h"
5 #include "blur_effect.h"
6 #include "effect_chain.h"
7 #include "util.h"
8
9 DiffusionEffect::DiffusionEffect()
10         : blur(new BlurEffect),
11           overlay_matte(new OverlayMatteEffect)
12 {
13 }
14
15 void DiffusionEffect::rewrite_graph(EffectChain *graph, Node *self)
16 {
17         assert(self->incoming_links.size() == 1);
18         Node *input = self->incoming_links[0];
19
20         Node *blur_node = graph->add_node(blur);
21         Node *overlay_matte_node = graph->add_node(overlay_matte);
22         graph->replace_receiver(self, overlay_matte_node);
23         graph->connect_nodes(input, blur_node);
24         graph->connect_nodes(blur_node, overlay_matte_node);
25         graph->replace_sender(self, overlay_matte_node);
26
27         self->disabled = true;
28 }
29
30 bool DiffusionEffect::set_float(const std::string &key, float value) {
31         if (key == "blurred_mix_amount") {
32                 return overlay_matte->set_float(key, value);
33         }
34         return blur->set_float(key, value);
35 }
36
37 OverlayMatteEffect::OverlayMatteEffect()
38         : blurred_mix_amount(0.3f)
39 {
40         register_float("blurred_mix_amount", &blurred_mix_amount);
41 }
42
43 std::string OverlayMatteEffect::output_fragment_shader()
44 {
45         return read_file("overlay_matte_effect.frag");
46 }