]> git.sesse.net Git - nageru/blob - blend.frag
Remove an unused uniform.
[nageru] / blend.frag
1 #version 450 core
2
3 in vec2 tc;
4 out vec4 rgba;
5
6 uniform sampler2D image0_tex, image1_tex, flow_tex;
7 uniform float alpha;
8
9 void main()
10 {
11         vec2 flow = texture(flow_tex, tc).xy;
12         vec4 I_0 = texture(image0_tex, tc - alpha * flow);
13         vec4 I_1 = texture(image1_tex, tc + (1.0f - alpha) * flow);
14
15         // Occlusion reasoning:
16
17         vec2 size = textureSize(image0_tex, 0);
18
19         // Follow the flow back to the initial point (where we sample I_0 from), then forward again.
20         // See how well we match the point we started at, which is out flow consistency.
21         float d0 = alpha * length(size * (texture(flow_tex, tc - alpha * flow).xy - flow));
22
23         // Same for d1.
24         float d1 = (1.0f - alpha) * length(size * (texture(flow_tex, tc + (1.0f - alpha) * flow).xy - flow));
25
26         if (max(d0, d1) < 3.0f) {  // Arbitrary constant, not all that tuned. The UW paper says 1.0 is fine for ground truth.
27                 // Both are visible, so blend.
28                 rgba = I_0 + alpha * (I_1 - I_0);
29         } else if (d0 < d1) {
30                 rgba = I_0;
31         } else {
32                 rgba = I_1;
33         }
34
35 }