3 layout(location=0) in vec2 position;
5 flat out vec2 flow, I_0_check_offset, I_1_check_offset;
7 uniform bool invert_flow;
8 uniform vec2 splat_size; // In 0..1 coordinates.
9 uniform vec2 inv_flow_size;
11 uniform sampler2D flow_tex;
15 int x = gl_InstanceID % textureSize(flow_tex, 0).x;
16 int y = gl_InstanceID / textureSize(flow_tex, 0).x;
18 // Find out where to splat this to.
19 // TODO: See if we can move some of these calculations into uniforms.
20 vec2 full_flow = texelFetch(flow_tex, ivec2(x, y), 0).xy;
23 full_flow = -full_flow;
24 splat_alpha = 1.0f - alpha;
28 full_flow *= inv_flow_size;
30 vec2 patch_center = (ivec2(x, y) + 0.5) * inv_flow_size + full_flow * splat_alpha;
31 image_pos = patch_center + splat_size * (position - 0.5);
34 I_0_check_offset = full_flow * -alpha;
35 I_1_check_offset = full_flow * (1.0f - alpha);
37 // The result of glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0) is:
39 // 2.000 0.000 0.000 -1.000
40 // 0.000 2.000 0.000 -1.000
41 // 0.000 0.000 -2.000 -1.000
42 // 0.000 0.000 0.000 1.000
43 gl_Position = vec4(2.0 * image_pos.x - 1.0, 2.0 * image_pos.y - 1.0, -1.0, 1.0);