]> git.sesse.net Git - movit/blob - glow_effect.h
Support other output formats than GL_RGBA16F; was easier than originally feared.
[movit] / glow_effect.h
1 #ifndef _MOVIT_GLOW_EFFECT_H
2 #define _MOVIT_GLOW_EFFECT_H 1
3
4 // Glow: Cut out the highlights of the image (everything above a certain threshold),
5 // blur them, and overlay them onto the original image.
6
7 #include <epoxy/gl.h>
8 #include <assert.h>
9 #include <string>
10
11 #include "effect.h"
12
13 namespace movit {
14
15 class BlurEffect;
16 class EffectChain;
17 class HighlightCutoffEffect;
18 class MixEffect;
19 class Node;
20
21 class GlowEffect : public Effect {
22 public:
23         GlowEffect();
24         virtual std::string effect_type_id() const { return "GlowEffect"; }
25
26         virtual bool needs_srgb_primaries() const { return false; }
27
28         virtual void rewrite_graph(EffectChain *graph, Node *self);
29         virtual bool set_float(const std::string &key, float value);
30
31         virtual std::string output_fragment_shader() {
32                 assert(false);
33         }
34         virtual void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) {
35                 assert(false);
36         }
37
38 private:
39         BlurEffect *blur;
40         HighlightCutoffEffect *cutoff;
41         MixEffect *mix;
42 };
43
44 // An effect that cuts out only the highlights of an image;
45 // anything at the cutoff or below is set to 0.0, and then all other pixels
46 // get the cutoff subtracted. Used only as part of GlowEffect.
47
48 class HighlightCutoffEffect : public Effect {
49 public:
50         HighlightCutoffEffect();
51         virtual std::string effect_type_id() const { return "HighlightCutoffEffect"; }
52         std::string output_fragment_shader();
53         
54         virtual AlphaHandling alpha_handling() const { return INPUT_PREMULTIPLIED_ALPHA_KEEP_BLANK; }
55         virtual bool one_to_one_sampling() const { return true; }
56
57 private:
58         float cutoff;
59 };
60
61 }  // namespace movit
62
63 #endif // !defined(_MOVIT_GLOW_EFFECT_H)