7 uniform int width_patches;
8 uniform vec2 patch_size; // In 0..1 coordinates.
9 uniform vec2 patch_spacing; // In 0..1 coordinates.
10 uniform sampler2D flow_tex;
14 int patch_x = gl_InstanceID % width_patches;
15 int patch_y = gl_InstanceID / width_patches;
17 // TODO: Lock the bottom left of the patch to an integer number of pixels?
19 image_pos = patch_spacing * ivec2(patch_x, patch_y) + patch_size * position;
21 // Find the flow value for this patch, and send it on to the fragment shader.
22 vec2 patch_center = patch_spacing * ivec2(patch_x, patch_y) + patch_size * vec2(0.5, 0.5);
23 flow_du = texture(flow_tex, patch_center).xy;
25 // The result of glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0) is:
27 // 2.000 0.000 0.000 -1.000
28 // 0.000 2.000 0.000 -1.000
29 // 0.000 0.000 -2.000 -1.000
30 // 0.000 0.000 0.000 1.000
31 gl_Position = vec4(2.0 * image_pos.x - 1.0, 2.0 * image_pos.y - 1.0, -1.0, 1.0);