1 uniform vec4 PREFIX(samples)[(R + 1) * (R + 1)];
3 vec4 FUNCNAME(vec2 tc) {
4 // The full matrix has five different symmetry cases, that look like this:
14 // We only store the lower-right part of the matrix:
20 // Case A: Top-left sample has no symmetry.
21 vec4 sum = PREFIX(samples)[0].z * INPUT(tc);
23 // Case B: Uppermost samples have left/right symmetry.
24 for (int x = 1; x <= R; ++x) {
25 vec4 sample = PREFIX(samples)[x];
26 sum += sample.z * (INPUT(tc - sample.xy) + INPUT(tc + sample.xy));
29 // Case C: Leftmost samples have top/bottom symmetry.
30 for (int y = 1; y <= R; ++y) {
31 vec4 sample = PREFIX(samples)[y * (R + 1)];
32 sum += sample.z * (INPUT(tc - sample.xy) + INPUT(tc + sample.xy));
35 // Case D: Diagonal samples have four-way symmetry.
36 for (int xy = 1; xy <= R; ++xy) {
37 vec4 sample = PREFIX(samples)[xy * (R + 1) + xy];
39 vec4 local_sum = INPUT(tc - sample.xy) + INPUT(tc + sample.xy);
41 local_sum += INPUT(tc - sample.xy) + INPUT(tc + sample.xy);
43 sum += sample.z * local_sum;
46 // Case *: All other samples have eight-way symmetry.
47 for (int y = 1; y <= R; ++y) {
48 for (int x = y + 1; x <= R; ++x) {
49 vec4 sample = PREFIX(samples)[y * (R + 1) + x];
50 vec2 mirror_sample = vec2(sample.x, -sample.y);
52 vec4 local_sum = INPUT(tc - sample.xy) + INPUT(tc + sample.xy);
53 local_sum += INPUT(tc - mirror_sample.xy) + INPUT(tc + mirror_sample.xy);
55 sample.xy = sample.yx;
56 mirror_sample.xy = mirror_sample.yx;
58 local_sum += INPUT(tc - sample.xy) + INPUT(tc + sample.xy);
59 local_sum += INPUT(tc - mirror_sample.xy) + INPUT(tc + mirror_sample.xy);
61 sum += sample.z * local_sum;