7 uniform sampler2D flow_tex;
11 // Patch placement: We want the outermost patches to have centers exactly in the
12 // image corners, so that the bottom-left patch has centre (0,0) and the
13 // upper-right patch has center (1,1). The position we get in is _almost_ there;
14 // since the quad's corners are in (0,0) and (1,1), the fragment shader will get
15 // centers in x=0.5/w, x=1.5/w and so on (and similar for y).
17 // In other words, find some f(x) = ax + b so that
20 // a (1.0 - 0.5 / w) + b = 1
26 vec2 flow_size = textureSize(flow_tex, 0);
27 vec2 a = flow_size / (flow_size - 1);
28 vec2 b = -1.0 / (2 * (flow_size - 1.0));
29 patch_center = a * position + b;
31 // The result of glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0) is:
33 // 2.000 0.000 0.000 -1.000
34 // 0.000 2.000 0.000 -1.000
35 // 0.000 0.000 -2.000 -1.000
36 // 0.000 0.000 0.000 1.000
37 gl_Position = vec4(2.0 * position.x - 1.0, 2.0 * position.y - 1.0, -1.0, 1.0);