]> git.sesse.net Git - movit/blobdiff - flat_input.frag
Remove some unneeded conversions from ResampleEffect. Speeds up texture generation...
[movit] / flat_input.frag
index d7c04cc5718f7fc5f0d38923932a601751426f41..78d4edd8224e4fc13e80411d51c088b5261b6d02 100644 (file)
@@ -1,4 +1,5 @@
-uniform sampler2D PREFIX(tex);
+// Implicit uniforms:
+// uniform sampler2D PREFIX(tex);
 
 vec4 FUNCNAME(vec2 tc) {
        // OpenGL's origin is bottom-left, but most graphics software assumes
@@ -6,5 +7,17 @@ vec4 FUNCNAME(vec2 tc) {
        // we flip the y coordinate.
        tc.y = 1.0 - tc.y;
 
-       return texture2D(PREFIX(tex), tc);
+       vec4 pixel = tex2D(PREFIX(tex), tc);
+
+       // These two are #defined to 0 or 1 in flat_input.cpp.
+#if FIXUP_SWAP_RB
+       pixel.rb = pixel.br;
+#endif
+#if FIXUP_RED_TO_GRAYSCALE
+       pixel.gb = pixel.rr;
+#endif
+       return pixel;
 }
+
+#undef FIXUP_SWAP_RB
+#undef FIXUP_RED_TO_GRAYSCALE