+ // Patch placement: We want the outermost patches to have centers exactly in the
+ // image corners, so that the bottom-left patch has centre (0,0) and the
+ // upper-right patch has center (1,1). The position we get in is _almost_ there;
+ // since the quad's corners are in (0,0) and (1,1), the fragment shader will get
+ // centers in x=0.5/w, x=1.5/w and so on (and similar for y).
+ //
+ // In other words, find some f(x) = ax + b so that
+ //
+ // a 0.5 / w + b = 0
+ // a (1.0 - 0.5 / w) + b = 1
+ //
+ // which gives
+ //
+ // a = 1 / (w - 1)
+ // b = w / 2 (w - 1)
+ vec2 a = flow_size / (flow_size - 1);
+ vec2 b = -1.0 / (2 * (flow_size - 1.0));
+ patch_center = a * position + b;
+