X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=glow_effect.h;h=340cf3d76888950ee3c536794c1bb32f1b360595;hp=1b5644ba62db9a835e911484e21897b3bb1abf27;hb=ad8a6bd307bcb9399a19f9100780f52513c8500d;hpb=f99ad333a7acbb6c8c995dbb036484ae8940c490 diff --git a/glow_effect.h b/glow_effect.h index 1b5644b..340cf3d 100644 --- a/glow_effect.h +++ b/glow_effect.h @@ -1,33 +1,63 @@ -#ifndef _GLOW_EFFECT_H -#define _GLOW_EFFECT_H 1 +#ifndef _MOVIT_GLOW_EFFECT_H +#define _MOVIT_GLOW_EFFECT_H 1 -// Glow: Simply add a blurred version of the image to itself. +// Glow: Cut out the highlights of the image (everything above a certain threshold), +// blur them, and overlay them onto the original image. + +#include +#include +#include #include "effect.h" +namespace movit { + class BlurEffect; +class EffectChain; +class HighlightCutoffEffect; class MixEffect; +class Node; class GlowEffect : public Effect { public: GlowEffect(); - virtual std::string effect_type_id() const { return "GlowEffect"; } + std::string effect_type_id() const override { return "GlowEffect"; } - virtual bool needs_srgb_primaries() const { return false; } + bool needs_srgb_primaries() const override { return false; } - virtual void add_self_to_effect_chain(EffectChain *chain, const std::vector &input); - virtual bool set_float(const std::string &key, float value); + void rewrite_graph(EffectChain *graph, Node *self) override; + bool set_float(const std::string &key, float value) override; - virtual std::string output_fragment_shader() { + std::string output_fragment_shader() override { assert(false); } - virtual void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) { + void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) override { assert(false); } private: BlurEffect *blur; + HighlightCutoffEffect *cutoff; MixEffect *mix; }; -#endif // !defined(_GLOW_EFFECT_H) +// An effect that cuts out only the highlights of an image; +// anything at the cutoff or below is set to 0.0, and then all other pixels +// get the cutoff subtracted. Used only as part of GlowEffect. + +class HighlightCutoffEffect : public Effect { +public: + HighlightCutoffEffect(); + std::string effect_type_id() const override { return "HighlightCutoffEffect"; } + std::string output_fragment_shader() override; + + AlphaHandling alpha_handling() const override { return INPUT_PREMULTIPLIED_ALPHA_KEEP_BLANK; } + bool strong_one_to_one_sampling() const override { return true; } + +private: + float cutoff; +}; + +} // namespace movit + +#endif // !defined(_MOVIT_GLOW_EFFECT_H)