From: Steinar H. Gunderson Date: Tue, 2 Oct 2012 12:18:37 +0000 (+0200) Subject: Add a mirror effect. X-Git-Tag: 1.0~425 X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=bc31a9072da1d9bfe417fd850e92cabe049fd593 Add a mirror effect. --- diff --git a/Makefile b/Makefile index 11482ba..917d2bd 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ CXX=g++ CXXFLAGS=-Wall -g LDFLAGS=-lSDL -lSDL_image -lGL OBJS=main.o util.o widgets.o effect.o effect_chain.o -OBJS += lift_gamma_gain_effect.o gamma_expansion_effect.o gamma_compression_effect.o colorspace_conversion_effect.o saturation_effect.o vignette_effect.o +OBJS += lift_gamma_gain_effect.o gamma_expansion_effect.o gamma_compression_effect.o colorspace_conversion_effect.o saturation_effect.o vignette_effect.o mirror_effect.o test: $(OBJS) $(CXX) -o test $(OBJS) $(LDFLAGS) diff --git a/effect_chain.cpp b/effect_chain.cpp index 04b698f..f860cad 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -14,6 +14,7 @@ #include "lift_gamma_gain_effect.h" #include "colorspace_conversion_effect.h" #include "saturation_effect.h" +#include "mirror_effect.h" #include "vignette_effect.h" #include "texture_enum.h" @@ -45,6 +46,8 @@ Effect *instantiate_effect(EffectId effect) return new LiftGammaGainEffect(); case EFFECT_SATURATION: return new SaturationEffect(); + case EFFECT_MIRROR: + return new MirrorEffect(); case EFFECT_VIGNETTE: return new VignetteEffect(); } diff --git a/effect_id.h b/effect_id.h index 644393d..3aa37eb 100644 --- a/effect_id.h +++ b/effect_id.h @@ -12,6 +12,7 @@ enum EffectId { EFFECT_SATURATION, // Spatial. + EFFECT_MIRROR, EFFECT_VIGNETTE, }; diff --git a/main.cpp b/main.cpp index 287e19a..2790bf8 100644 --- a/main.cpp +++ b/main.cpp @@ -176,6 +176,7 @@ int main(int argc, char **argv) Effect *lift_gamma_gain_effect = chain.add_effect(EFFECT_LIFT_GAMMA_GAIN); Effect *saturation_effect = chain.add_effect(EFFECT_SATURATION); Effect *vignette_effect = chain.add_effect(EFFECT_VIGNETTE); + //chain.add_effect(EFFECT_MIRROR); chain.add_output(inout_format); chain.finalize(); @@ -258,6 +259,7 @@ int main(int argc, char **argv) update_hsv(lift_gamma_gain_effect, saturation_effect); vignette_effect->set_float("radius", radius); vignette_effect->set_float("inner_radius", inner_radius); + //vignette_effect->set_vec2("center", (float[]){ 0.7f, 0.5f }); chain.render_to_screen(src_img); glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 1); diff --git a/mirror_effect.cpp b/mirror_effect.cpp new file mode 100644 index 0000000..f772821 --- /dev/null +++ b/mirror_effect.cpp @@ -0,0 +1,16 @@ +#include "mirror_effect.h" +#include "util.h" + +MirrorEffect::MirrorEffect() +{ +} + +std::string MirrorEffect::output_vertex_shader() +{ + return read_file("mirror_effect.vert"); +} + +std::string MirrorEffect::output_fragment_shader() +{ + return read_file("identity.frag"); +} diff --git a/mirror_effect.h b/mirror_effect.h new file mode 100644 index 0000000..6e75b26 --- /dev/null +++ b/mirror_effect.h @@ -0,0 +1,13 @@ +#ifndef _MIRROR_EFFECT_H +#define _MIRROR_EFFECT_H 1 + +#include "effect.h" + +class MirrorEffect : public Effect { +public: + MirrorEffect(); + std::string output_vertex_shader(); + std::string output_fragment_shader(); +}; + +#endif // !defined(_MIRROR_EFFECT_H) diff --git a/mirror_effect.vert b/mirror_effect.vert new file mode 100644 index 0000000..8c29945 --- /dev/null +++ b/mirror_effect.vert @@ -0,0 +1,4 @@ +vec2 FUNCNAME() +{ + return vec2(1.0, 0.0) + LAST_INPUT() * vec2(-1.0, 1.0); +}