]> git.sesse.net Git - movit/blob - luma_mix_effect.frag
Remove obsolete file.
[movit] / luma_mix_effect.frag
1 uniform float PREFIX(progress_mul_w_plus_one);
2
3 vec4 FUNCNAME(vec2 tc) {
4         vec4 first = INPUT1(tc);
5         vec4 second = INPUT2(tc);
6
7         // We treat the luma as going from 0 to w, where w is the transition width
8         // (wider means the boundary between transitioned and non-transitioned
9         // will be harder, while w=0 is essentially just a straight fade).
10         // We need to map this 0..w range in the luma image to a (clamped) 0..1
11         // range for how far this pixel has come in a fade. At the very
12         // beginning, we can visualize it like this, where every pixel is in
13         // the state 0.0 (100% first image, 0% second image):
14         //
15         //         0                     w
16         //   luma: |---------------------|
17         //   mix:                        |----|
18         //                               0    1
19         //
20         // Then as we progress, eventually the luma range should move to the right
21         // so that more pixels start moving towards higher mix value:
22         //
23         //           0                     w
24         //   luma:   |---------------------|
25         //   mix:                        |----|
26         //                               0    1
27         //
28         // and at the very end, all pixels should be in the state 1.0 (0% first image,
29         // 100% second image):
30         //
31         //                                    0                     w
32         //   luma:                            |---------------------|
33         //   mix:                        |----|
34         //                               0    1
35         //
36         // So clearly, it should move (w+1) units to the right, and apart from that
37         // just stay a simple mapping.
38         float w = PREFIX(transition_width);
39         float luma = INPUT3(tc).x * w;
40         float m = clamp((luma - w) + PREFIX(progress_mul_w_plus_one), 0.0, 1.0);
41
42         return mix(first, second, m);
43 }