]> git.sesse.net Git - movit/blobdiff - luma_mix_effect.frag
Release Movit 1.3.2. (From a branch, since I do not want to break ABI compatibility...
[movit] / luma_mix_effect.frag
index 21365a69e1eaaeeaf9427a6fad887d3063b61d31..84af47cab83d68b51044f1dfd2c3bf4cb98568bf 100644 (file)
@@ -1,4 +1,6 @@
-uniform float PREFIX(progress_mul_w_plus_one);
+// Implicit uniforms:
+// uniform float PREFIX(progress_mul_w_plus_one);
+// uniform bool PREFIX(bool_inverse);
 
 vec4 FUNCNAME(vec2 tc) {
        vec4 first = INPUT1(tc);
@@ -14,31 +16,33 @@ vec4 FUNCNAME(vec2 tc) {
        //
        //         0                     w
        //   luma: |---------------------|
-        //   mix:                        |----|
-        //                               0    1
+       //   mix:                        |----|
+       //                               0    1
        //
        // Then as we progress, eventually the luma range should move to the right
        // so that more pixels start moving towards higher mix value:
        //
        //           0                     w
        //   luma:   |---------------------|
-        //   mix:                        |----|
-        //                               0    1
+       //   mix:                        |----|
+       //                               0    1
        //
        // and at the very end, all pixels should be in the state 1.0 (0% first image,
        // 100% second image):
        //
        //                                    0                     w
        //   luma:                            |---------------------|
-        //   mix:                        |----|
-        //                               0    1
+       //   mix:                        |----|
+       //                               0    1
        //
        // So clearly, it should move (w+1) units to the right, and apart from that
        // just stay a simple mapping.
        float w = PREFIX(transition_width);
-       float luma = INPUT3(tc).x * w;
-       float m = clamp((luma - w) + PREFIX(progress_mul_w_plus_one), 0.0, 1.0);
+       float luma = INPUT3(tc).x;
+       if (PREFIX(bool_inverse)) {
+               luma = 1.0 - luma;
+       }
+       float m = clamp((luma * w - w) + PREFIX(progress_mul_w_plus_one), 0.0, 1.0);
 
        return mix(first, second, m);
-//     return vec4(luma, luma, luma, 1.0);
 }