+ int num_patches = textureSize(flow_tex, 0).x * textureSize(flow_tex, 0).y;
+ int patch_layer = gl_InstanceID / num_patches;
+ int patch_x = gl_InstanceID % textureSize(flow_tex, 0).x;
+ int patch_y = (gl_InstanceID % num_patches) / textureSize(flow_tex, 0).x;
+
+ // Convert the patch index to being the full 0..1 range, to match where
+ // the motion search puts the patches. We don't bother with the locking
+ // to texel centers, though.
+ vec2 patch_center = ivec2(patch_x, patch_y) / (textureSize(flow_tex, 0).xy - 1.0);