Add a mirror effect.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 2 Oct 2012 12:18:37 +0000 (14:18 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 2 Oct 2012 12:18:37 +0000 (14:18 +0200)
Makefile
effect_chain.cpp
effect_id.h
main.cpp
mirror_effect.cpp [new file with mode: 0644]
mirror_effect.h [new file with mode: 0644]
mirror_effect.vert [new file with mode: 0644]

index 11482ba..917d2bd 100644 (file)
--- 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)
index 04b698f..f860cad 100644 (file)
@@ -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();
        }
index 644393d..3aa37eb 100644 (file)
@@ -12,6 +12,7 @@ enum EffectId {
        EFFECT_SATURATION,
 
        // Spatial.
+       EFFECT_MIRROR,
        EFFECT_VIGNETTE,
 };
 
index 287e19a..2790bf8 100644 (file)
--- 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 (file)
index 0000000..f772821
--- /dev/null
@@ -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 (file)
index 0000000..6e75b26
--- /dev/null
@@ -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 (file)
index 0000000..8c29945
--- /dev/null
@@ -0,0 +1,4 @@
+vec2 FUNCNAME()
+{
+       return vec2(1.0, 0.0) + LAST_INPUT() * vec2(-1.0, 1.0);
+}