bayerCell function
BayerCell from reflections.frag and light_shafts.frag: one cell of a
4x4 Bayer matrix at window position (x, y), in [0, 1).
Implementation
double bayerCell(double x, double y) {
const table = <int>[0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5];
final cx = x.floor() % 4;
final cy = y.floor() % 4;
final index = ((cy < 0 ? cy + 4 : cy) * 4) + (cx < 0 ? cx + 4 : cx);
return table[index] / 16.0;
}