X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=glow_effect.cpp;h=064cdac99950e561d9817f4d1115f252451e067b;hp=0868eb057662909fdc10e3544d996f1dc6bf6db6;hb=bbf22bd4cc8c00add6b934f19d30a099241ffd84;hpb=e655afd53f2e56938bd4e7f72640eff56ef4a1ee diff --git a/glow_effect.cpp b/glow_effect.cpp index 0868eb0..064cdac 100644 --- a/glow_effect.cpp +++ b/glow_effect.cpp @@ -9,10 +9,13 @@ GlowEffect::GlowEffect() : blur(new BlurEffect), + cutoff(new HighlightCutoffEffect), mix(new MixEffect) { - mix->set_float("strength_first", 1.0f); - mix->set_float("strength_second", 0.3f); + CHECK(blur->set_float("radius", 20.0f)); + CHECK(mix->set_float("strength_first", 1.0f)); + CHECK(mix->set_float("strength_second", 1.0f)); + CHECK(cutoff->set_float("cutoff", 0.2f)); } void GlowEffect::rewrite_graph(EffectChain *graph, Node *self) @@ -22,8 +25,10 @@ void GlowEffect::rewrite_graph(EffectChain *graph, Node *self) Node *blur_node = graph->add_node(blur); Node *mix_node = graph->add_node(mix); + Node *cutoff_node = graph->add_node(cutoff); graph->replace_receiver(self, mix_node); - graph->connect_nodes(input, blur_node); + graph->connect_nodes(input, cutoff_node); + graph->connect_nodes(cutoff_node, blur_node); graph->connect_nodes(blur_node, mix_node); graph->replace_sender(self, mix_node); @@ -34,5 +39,19 @@ bool GlowEffect::set_float(const std::string &key, float value) { if (key == "blurred_mix_amount") { return mix->set_float("strength_second", value); } + if (key == "highlight_cutoff") { + return cutoff->set_float("cutoff", value); + } return blur->set_float(key, value); } + +HighlightCutoffEffect::HighlightCutoffEffect() + : cutoff(0.0f) +{ + register_float("cutoff", &cutoff); +} + +std::string HighlightCutoffEffect::output_fragment_shader() +{ + return read_file("highlight_cutoff_effect.frag"); +}