]> git.sesse.net Git - movit/blob - diffusion_effect.h
Bind input textures to the right sampler, and do it even if we do not need to update...
[movit] / diffusion_effect.h
1 #ifndef _DIFFUSION_EFFECT_H
2 #define _DIFFUSION_EFFECT_H 1
3
4 // There are many different effects that go under the name of "diffusion",
5 // seemingly all of the inspired by the effect you get when you put a
6 // diffusion filter in front of your camera lens. The effect most people
7 // want is a general flattening/smoothing of the light, and reduction of
8 // fine detail (most notably, blemishes in people's skin), without ruining
9 // edges, which a regular blur would do.
10 //
11 // We do a relatively simple version, sometimes known as "white diffusion",
12 // where we first blur the picture, and then overlay it on the original
13 // using the original as a matte.
14
15 #include "effect.h"
16
17 class BlurEffect;
18 class OverlayMatteEffect;
19
20 class DiffusionEffect : public Effect {
21 public:
22         DiffusionEffect();
23
24         virtual void add_self_to_effect_chain(EffectChain *chain, const std::vector<Effect *> &input);
25         virtual bool set_float(const std::string &key, float value);
26         
27         virtual std::string output_fragment_shader() {
28                 assert(false);
29         }
30         virtual void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) {
31                 assert(false);
32         }
33
34 private:
35         BlurEffect *blur;
36         OverlayMatteEffect *overlay_matte;
37 };
38
39 // Used internally by DiffusionEffect; combines the blurred and the original
40 // version using the original as a matte.
41 class OverlayMatteEffect : public Effect {
42 public:
43         OverlayMatteEffect();
44         std::string output_fragment_shader();
45
46         unsigned num_inputs() const { return 2; }
47
48 private:
49         float blurred_mix_amount;
50 };
51
52
53 #endif // !defined(_DIFFUSION_EFFECT_H)