2 // uniform vec4 PREFIX(samples)[(R + 1) * (R + 1)];
4 vec4 FUNCNAME(vec2 tc) {
5 // The full matrix has five different symmetry cases, that look like this:
15 // We only store the lower-right part of the matrix:
22 // Case A: Top-left sample has no symmetry.
23 vec4 sum = PREFIX(samples)[0].z * INPUT(tc);
25 // Case B: Uppermost samples have left/right symmetry.
26 for (int x = 1; x <= R; ++x) {
27 vec4 sample = PREFIX(samples)[x];
28 sum += sample.z * (INPUT(tc - sample.xy) + INPUT(tc + sample.xy));
31 // Case C: Leftmost samples have top/bottom symmetry.
32 for (int y = 1; y <= R; ++y) {
33 vec4 sample = PREFIX(samples)[y * (R + 1)];
34 sum += sample.z * (INPUT(tc - sample.xy) + INPUT(tc + sample.xy));
37 // Case D: All other samples have four-way symmetry.
38 // (Actually we have eight-way, but since we are using normalized
39 // coordinates, we can't just flip x and y.)
40 for (int y = 1; y <= R; ++y) {
41 for (int x = 1; x <= R; ++x) {
42 vec4 sample = PREFIX(samples)[y * (R + 1) + x];
43 vec2 mirror_sample = vec2(sample.x, -sample.y);
45 vec4 local_sum = INPUT(tc - sample.xy) + INPUT(tc + sample.xy);
46 local_sum += INPUT(tc - mirror_sample.xy) + INPUT(tc + mirror_sample.xy);
47 sum += sample.z * local_sum;