6 uniform sampler2D image0_tex, image1_tex, flow_tex;
7 uniform float alpha, flow_consistency_tolerance;
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);
15 // Occlusion reasoning:
17 vec2 size = textureSize(image0_tex, 0);
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));
24 float d1 = (1.0f - alpha) * length(size * (texture(flow_tex, tc + (1.0f - alpha) * flow).xy - flow));
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);