1 #ifndef _MOVIT_DIFFUSION_EFFECT_H
2 #define _MOVIT_DIFFUSION_EFFECT_H 1
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.
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.
26 class OverlayMatteEffect;
28 class DiffusionEffect : public Effect {
32 std::string effect_type_id() const override { return "DiffusionEffect"; }
34 void rewrite_graph(EffectChain *graph, Node *self) override;
35 bool set_float(const std::string &key, float value) override;
37 std::string output_fragment_shader() override {
40 void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) override {
46 OverlayMatteEffect *overlay_matte;
47 bool owns_overlay_matte;
50 // Used internally by DiffusionEffect; combines the blurred and the original
51 // version using the original as a matte.
52 class OverlayMatteEffect : public Effect {
55 std::string effect_type_id() const override { return "OverlayMatteEffect"; }
56 std::string output_fragment_shader() override;
57 AlphaHandling alpha_handling() const override { return INPUT_PREMULTIPLIED_ALPHA_KEEP_BLANK; }
59 unsigned num_inputs() const override { return 2; }
60 bool strong_one_to_one_sampling() const override { return true; }
63 float blurred_mix_amount;
68 #endif // !defined(_MOVIT_DIFFUSION_EFFECT_H)