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:
21 // Case A: Top-left sample has no symmetry.
22 vec4 sum = PREFIX(samples)[0].z * INPUT(tc);
24 // Case B: Uppermost samples have left/right symmetry.
25 for (int x = 1; x <= R; ++x) {
26 vec4 sample = PREFIX(samples)[x];
27 sum += sample.z * (INPUT(tc - sample.xy) + INPUT(tc + sample.xy));
30 // Case C: Leftmost samples have top/bottom symmetry.
31 for (int y = 1; y <= R; ++y) {
32 vec4 sample = PREFIX(samples)[y * (R + 1)];
33 sum += sample.z * (INPUT(tc - sample.xy) + INPUT(tc + sample.xy));
36 // Case D: All other samples have four-way symmetry.
37 // (Actually we have eight-way, but since we are using normalized
38 // coordinates, we can't just flip x and y.)
39 for (int y = 1; y < R; ++y) {
40 for (int x = 1; x <= R; ++x) {
41 vec4 sample = PREFIX(samples)[y * (R + 1) + x];
42 vec2 mirror_sample = vec2(sample.x, -sample.y);
44 vec4 local_sum = INPUT(tc - sample.xy) + INPUT(tc + sample.xy);
45 local_sum += INPUT(tc - mirror_sample.xy) + INPUT(tc + mirror_sample.xy);
46 sum += sample.z * local_sum;