1 // DIRECTION_VERTICAL will be #defined to 1 if we are scaling vertically,
4 uniform sampler2D PREFIX(sample_tex);
5 uniform int PREFIX(num_samples);
6 uniform float PREFIX(num_loops);
7 uniform float PREFIX(sample_x_scale);
8 uniform float PREFIX(sample_x_offset);
9 uniform float PREFIX(slice_height);
11 // Sample a single weight. First fetch information about where to sample
12 // and the weight from sample_tex, and then read the pixel itself.
13 vec4 PREFIX(do_sample)(vec2 tc, int i)
16 sample_tc.x = float(i) * PREFIX(sample_x_scale) + PREFIX(sample_x_offset);
17 #if DIRECTION_VERTICAL
18 sample_tc.y = tc.y * PREFIX(num_loops);
20 sample_tc.y = tc.x * PREFIX(num_loops);
22 vec2 sample = texture2D(PREFIX(sample_tex), sample_tc).rg;
24 #if DIRECTION_VERTICAL
25 tc.y = sample.g + floor(sample_tc.y) * PREFIX(slice_height);
27 tc.x = sample.g + floor(sample_tc.y) * PREFIX(slice_height);
29 return vec4(sample.r) * INPUT(tc);
32 vec4 FUNCNAME(vec2 tc) {
33 vec4 sum = PREFIX(do_sample)(tc, 0);
34 for (int i = 1; i < PREFIX(num_samples); ++i) {
35 sum += PREFIX(do_sample)(tc, i);
40 #undef DIRECTION_VERTICAL