Skip to content

Instantly share code, notes, and snippets.

@EmmaEwert
Created August 9, 2018 00:06
Show Gist options
  • Save EmmaEwert/c2689ef50de22e21502a3e2048e01454 to your computer and use it in GitHub Desktop.
Save EmmaEwert/c2689ef50de22e21502a3e2048e01454 to your computer and use it in GitHub Desktop.
Precomputed 64×64 Bayer Matrix for realtime dithering
static const int Indices[4096] = {
0, 3584, 896, 3360, 224, 3808, 840, 3528, 56, 3640, 952, 3347, 211, 3795, 883, 3571, 15, 3599, 911, 3375, 239, 3823, 836, 3524, 52, 3636, 948, 3356, 220, 3804, 892, 3580, 2, 3586, 898, 3362, 226, 3810, 842, 3530, 58, 3642, 954, 3345, 209, 3793, 881, 3569, 13, 3597, 909, 3373, 237, 3821, 838, 3526, 54, 3638, 950, 3358, 222, 3806, 894, 3582,
2987, 1792, 2240, 1120, 2912, 2016, 2072, 1176, 2968, 1848, 2296, 1107, 2899, 2003, 2087, 1191, 2983, 1807, 2255, 1135, 2927, 2031, 2068, 1172, 2964, 1844, 2292, 1116, 2908, 2012, 2089, 1193, 2985, 1794, 2242, 1122, 2914, 2018, 2074, 1178, 2970, 1850, 2298, 1105, 2897, 2001, 2085, 1189, 2981, 1805, 2253, 1133, 2925, 2029, 2070, 1174, 2966, 1846, 2294, 1118, 2910, 2014, 2091, 1195,
747, 3136, 448, 4032, 560, 3248, 280, 3864, 728, 3192, 504, 4088, 519, 3207, 295, 3879, 743, 3151, 463, 4047, 575, 3263, 276, 3860, 724, 3188, 500, 4084, 521, 3209, 297, 3881, 745, 3138, 450, 4034, 562, 3250, 282, 3866, 730, 3194, 506, 4090, 517, 3205, 293, 3877, 741, 3149, 461, 4045, 573, 3261, 278, 3862, 726, 3190, 502, 4086, 523, 3211, 299, 3883,
2539, 1344, 2576, 1680, 2352, 1456, 2800, 1624, 2520, 1400, 2604, 1708, 2311, 1415, 2759, 1639, 2535, 1359, 2591, 1695, 2367, 1471, 2815, 1620, 2516, 1396, 2593, 1697, 2313, 1417, 2761, 1641, 2537, 1346, 2578, 1682, 2354, 1458, 2802, 1626, 2522, 1402, 2606, 1710, 2309, 1413, 2757, 1637, 2533, 1357, 2589, 1693, 2365, 1469, 2813, 1622, 2518, 1398, 2595, 1699, 2315, 1419, 2763, 1643,
187, 3771, 784, 3472, 112, 3696, 1008, 3416, 140, 3724, 812, 3500, 71, 3655, 967, 3431, 183, 3767, 799, 3487, 127, 3711, 1023, 3412, 129, 3713, 801, 3489, 73, 3657, 969, 3433, 185, 3769, 786, 3474, 114, 3698, 1010, 3418, 142, 3726, 814, 3502, 69, 3653, 965, 3429, 181, 3765, 797, 3485, 125, 3709, 1021, 3414, 131, 3715, 803, 3491, 75, 3659, 971, 3435,
2875, 1979, 2128, 1232, 3024, 1904, 2212, 1036, 2828, 1932, 2156, 1260, 3052, 1863, 2199, 1079, 2871, 1975, 2143, 1247, 3039, 1919, 2218, 1025, 2817, 1921, 2145, 1249, 3041, 1865, 2201, 1081, 2873, 1977, 2130, 1234, 3026, 1906, 2214, 1038, 2830, 1934, 2158, 1262, 3054, 1861, 2197, 1077, 2869, 1973, 2141, 1245, 3037, 1917, 2216, 1027, 2819, 1923, 2147, 1251, 3043, 1867, 2203, 1083,
635, 3323, 336, 3920, 644, 3108, 420, 4004, 588, 3276, 364, 3948, 700, 3095, 407, 3991, 631, 3319, 351, 3935, 650, 3114, 426, 4010, 577, 3265, 353, 3937, 689, 3097, 409, 3993, 633, 3321, 338, 3922, 646, 3110, 422, 4006, 590, 3278, 366, 3950, 702, 3093, 405, 3989, 629, 3317, 349, 3933, 648, 3112, 424, 4008, 579, 3267, 355, 3939, 691, 3099, 411, 3995,
2427, 1531, 2735, 1540, 2436, 1316, 2660, 1764, 2380, 1484, 2716, 1596, 2492, 1303, 2647, 1751, 2423, 1527, 2722, 1546, 2442, 1322, 2666, 1770, 2369, 1473, 2705, 1585, 2481, 1305, 2649, 1753, 2425, 1529, 2733, 1542, 2438, 1318, 2662, 1766, 2382, 1486, 2718, 1598, 2494, 1301, 2645, 1749, 2421, 1525, 2720, 1544, 2440, 1320, 2664, 1768, 2371, 1475, 2707, 1587, 2483, 1307, 2651, 1755,
47, 3631, 943, 3332, 196, 3780, 868, 3556, 28, 3612, 924, 3388, 252, 3836, 855, 3543, 34, 3618, 930, 3338, 202, 3786, 874, 3562, 17, 3601, 913, 3377, 241, 3825, 857, 3545, 45, 3629, 941, 3334, 198, 3782, 870, 3558, 30, 3614, 926, 3390, 254, 3838, 853, 3541, 32, 3616, 928, 3336, 200, 3784, 872, 3560, 19, 3603, 915, 3379, 243, 3827, 859, 3547,
2959, 1839, 2287, 1092, 2884, 1988, 2100, 1204, 2996, 1820, 2268, 1148, 2940, 2044, 2050, 1154, 2946, 1826, 2274, 1098, 2890, 1994, 2106, 1210, 3002, 1809, 2257, 1137, 2929, 2033, 2061, 1165, 2957, 1837, 2285, 1094, 2886, 1990, 2102, 1206, 2998, 1822, 2270, 1150, 2942, 2046, 2048, 1152, 2944, 1824, 2272, 1096, 2888, 1992, 2104, 1208, 3000, 1811, 2259, 1139, 2931, 2035, 2063, 1167,
719, 3183, 495, 4079, 532, 3220, 308, 3892, 756, 3164, 476, 4060, 553, 3241, 258, 3842, 706, 3170, 482, 4066, 538, 3226, 314, 3898, 762, 3153, 465, 4049, 549, 3237, 269, 3853, 717, 3181, 493, 4077, 534, 3222, 310, 3894, 758, 3166, 478, 4062, 555, 3243, 256, 3840, 704, 3168, 480, 4064, 536, 3224, 312, 3896, 760, 3155, 467, 4051, 551, 3239, 271, 3855,
2511, 1391, 2623, 1727, 2324, 1428, 2772, 1652, 2548, 1372, 2569, 1673, 2345, 1449, 2793, 1602, 2498, 1378, 2610, 1714, 2330, 1434, 2778, 1658, 2554, 1361, 2565, 1669, 2341, 1445, 2789, 1613, 2509, 1389, 2621, 1725, 2326, 1430, 2774, 1654, 2550, 1374, 2571, 1675, 2347, 1451, 2795, 1600, 2496, 1376, 2608, 1712, 2328, 1432, 2776, 1656, 2552, 1363, 2567, 1671, 2343, 1447, 2791, 1615,
159, 3743, 831, 3519, 84, 3668, 980, 3444, 161, 3745, 777, 3465, 105, 3689, 1001, 3394, 146, 3730, 818, 3506, 90, 3674, 986, 3450, 174, 3758, 773, 3461, 101, 3685, 997, 3405, 157, 3741, 829, 3517, 86, 3670, 982, 3446, 163, 3747, 779, 3467, 107, 3691, 1003, 3392, 144, 3728, 816, 3504, 88, 3672, 984, 3448, 172, 3756, 775, 3463, 103, 3687, 999, 3407,
2847, 1951, 2175, 1279, 3071, 1876, 2177, 1057, 2849, 1953, 2121, 1225, 3017, 1897, 2233, 1042, 2834, 1938, 2162, 1266, 3058, 1882, 2190, 1070, 2862, 1966, 2117, 1221, 3013, 1893, 2229, 1053, 2845, 1949, 2173, 1277, 3069, 1878, 2179, 1059, 2851, 1955, 2123, 1227, 3019, 1899, 2235, 1040, 2832, 1936, 2160, 1264, 3056, 1880, 2188, 1068, 2860, 1964, 2119, 1223, 3015, 1895, 2231, 1055,
607, 3295, 383, 3967, 682, 3073, 385, 3969, 609, 3297, 329, 3913, 665, 3129, 441, 4025, 594, 3282, 370, 3954, 678, 3086, 398, 3982, 622, 3310, 325, 3909, 661, 3125, 437, 4021, 605, 3293, 381, 3965, 680, 3075, 387, 3971, 611, 3299, 331, 3915, 667, 3131, 443, 4027, 592, 3280, 368, 3952, 676, 3084, 396, 3980, 620, 3308, 327, 3911, 663, 3127, 439, 4023,
2399, 1503, 2698, 1578, 2474, 1281, 2625, 1729, 2401, 1505, 2737, 1561, 2457, 1337, 2681, 1785, 2386, 1490, 2694, 1574, 2470, 1294, 2638, 1742, 2414, 1518, 2750, 1557, 2453, 1333, 2677, 1781, 2397, 1501, 2696, 1576, 2472, 1283, 2627, 1731, 2403, 1507, 2739, 1563, 2459, 1339, 2683, 1787, 2384, 1488, 2692, 1572, 2468, 1292, 2636, 1740, 2412, 1516, 2748, 1559, 2455, 1335, 2679, 1783,
10, 3594, 906, 3370, 234, 3818, 833, 3521, 49, 3633, 945, 3353, 217, 3801, 889, 3577, 6, 3590, 902, 3366, 230, 3814, 846, 3534, 62, 3646, 958, 3349, 213, 3797, 885, 3573, 8, 3592, 904, 3368, 232, 3816, 835, 3523, 51, 3635, 947, 3355, 219, 3803, 891, 3579, 4, 3588, 900, 3364, 228, 3812, 844, 3532, 60, 3644, 956, 3351, 215, 3799, 887, 3575,
2978, 1802, 2250, 1130, 2922, 2026, 2065, 1169, 2961, 1841, 2289, 1113, 2905, 2009, 2093, 1197, 2989, 1798, 2246, 1126, 2918, 2022, 2078, 1182, 2974, 1854, 2302, 1109, 2901, 2005, 2080, 1184, 2976, 1800, 2248, 1128, 2920, 2024, 2067, 1171, 2963, 1843, 2291, 1115, 2907, 2011, 2095, 1199, 2991, 1796, 2244, 1124, 2916, 2020, 2076, 1180, 2972, 1852, 2300, 1111, 2903, 2007, 2082, 1186,
738, 3146, 458, 4042, 570, 3258, 273, 3857, 721, 3185, 497, 4081, 525, 3213, 301, 3885, 749, 3142, 454, 4038, 566, 3254, 286, 3870, 734, 3198, 510, 4096, 512, 3200, 288, 3872, 736, 3144, 456, 4040, 568, 3256, 275, 3859, 723, 3187, 499, 4083, 527, 3215, 303, 3887, 751, 3140, 452, 4036, 564, 3252, 284, 3868, 732, 3196, 508, 4092, 514, 3202, 290, 3874,
2530, 1354, 2586, 1690, 2362, 1466, 2810, 1617, 2513, 1393, 2597, 1701, 2317, 1421, 2765, 1645, 2541, 1350, 2582, 1686, 2358, 1462, 2806, 1630, 2526, 1406, 2603, 1707, 2304, 1408, 2752, 1632, 2528, 1352, 2584, 1688, 2360, 1464, 2808, 1619, 2515, 1395, 2599, 1703, 2319, 1423, 2767, 1647, 2543, 1348, 2580, 1684, 2356, 1460, 2804, 1628, 2524, 1404, 2601, 1705, 2306, 1410, 2754, 1634,
178, 3762, 794, 3482, 122, 3706, 1018, 3409, 133, 3717, 805, 3493, 77, 3661, 973, 3437, 189, 3773, 790, 3478, 118, 3702, 1014, 3422, 139, 3723, 811, 3499, 64, 3648, 960, 3424, 176, 3760, 792, 3480, 120, 3704, 1016, 3411, 135, 3719, 807, 3495, 79, 3663, 975, 3439, 191, 3775, 788, 3476, 116, 3700, 1012, 3420, 137, 3721, 809, 3497, 66, 3650, 962, 3426,
2866, 1970, 2138, 1242, 3034, 1914, 2222, 1029, 2821, 1925, 2149, 1253, 3045, 1869, 2205, 1085, 2877, 1981, 2134, 1238, 3030, 1910, 2211, 1035, 2827, 1931, 2155, 1259, 3051, 1856, 2192, 1072, 2864, 1968, 2136, 1240, 3032, 1912, 2220, 1031, 2823, 1927, 2151, 1255, 3047, 1871, 2207, 1087, 2879, 1983, 2132, 1236, 3028, 1908, 2209, 1033, 2825, 1929, 2153, 1257, 3049, 1858, 2194, 1074,
626, 3314, 346, 3930, 654, 3118, 430, 4014, 581, 3269, 357, 3941, 693, 3101, 413, 3997, 637, 3325, 342, 3926, 643, 3107, 419, 4003, 587, 3275, 363, 3947, 699, 3088, 400, 3984, 624, 3312, 344, 3928, 652, 3116, 428, 4012, 583, 3271, 359, 3943, 695, 3103, 415, 3999, 639, 3327, 340, 3924, 641, 3105, 417, 4001, 585, 3273, 361, 3945, 697, 3090, 402, 3986,
2418, 1522, 2726, 1550, 2446, 1326, 2670, 1774, 2373, 1477, 2709, 1589, 2485, 1309, 2653, 1757, 2429, 1533, 2728, 1539, 2435, 1315, 2659, 1763, 2379, 1483, 2715, 1595, 2491, 1296, 2640, 1744, 2416, 1520, 2724, 1548, 2444, 1324, 2668, 1772, 2375, 1479, 2711, 1591, 2487, 1311, 2655, 1759, 2431, 1535, 2730, 1537, 2433, 1313, 2657, 1761, 2377, 1481, 2713, 1593, 2489, 1298, 2642, 1746,
38, 3622, 934, 3342, 206, 3790, 878, 3566, 21, 3605, 917, 3381, 245, 3829, 861, 3549, 40, 3624, 936, 3331, 195, 3779, 867, 3555, 27, 3611, 923, 3387, 251, 3835, 848, 3536, 36, 3620, 932, 3340, 204, 3788, 876, 3564, 23, 3607, 919, 3383, 247, 3831, 863, 3551, 42, 3626, 938, 3329, 193, 3777, 865, 3553, 25, 3609, 921, 3385, 249, 3833, 850, 3538,
2950, 1830, 2278, 1102, 2894, 1998, 2110, 1214, 3006, 1813, 2261, 1141, 2933, 2037, 2056, 1160, 2952, 1832, 2280, 1091, 2883, 1987, 2099, 1203, 2995, 1819, 2267, 1147, 2939, 2043, 2052, 1156, 2948, 1828, 2276, 1100, 2892, 1996, 2108, 1212, 3004, 1815, 2263, 1143, 2935, 2039, 2058, 1162, 2954, 1834, 2282, 1089, 2881, 1985, 2097, 1201, 2993, 1817, 2265, 1145, 2937, 2041, 2054, 1158,
710, 3174, 486, 4070, 542, 3230, 318, 3902, 766, 3157, 469, 4053, 544, 3232, 264, 3848, 712, 3176, 488, 4072, 531, 3219, 307, 3891, 755, 3163, 475, 4059, 559, 3247, 260, 3844, 708, 3172, 484, 4068, 540, 3228, 316, 3900, 764, 3159, 471, 4055, 546, 3234, 266, 3850, 714, 3178, 490, 4074, 529, 3217, 305, 3889, 753, 3161, 473, 4057, 557, 3245, 262, 3846,
2502, 1382, 2614, 1718, 2334, 1438, 2782, 1662, 2558, 1365, 2560, 1664, 2336, 1440, 2784, 1608, 2504, 1384, 2616, 1720, 2323, 1427, 2771, 1651, 2547, 1371, 2575, 1679, 2351, 1455, 2799, 1604, 2500, 1380, 2612, 1716, 2332, 1436, 2780, 1660, 2556, 1367, 2562, 1666, 2338, 1442, 2786, 1610, 2506, 1386, 2618, 1722, 2321, 1425, 2769, 1649, 2545, 1369, 2573, 1677, 2349, 1453, 2797, 1606,
150, 3734, 822, 3510, 94, 3678, 990, 3454, 171, 3755, 768, 3456, 96, 3680, 992, 3400, 152, 3736, 824, 3512, 83, 3667, 979, 3443, 167, 3751, 783, 3471, 111, 3695, 1007, 3396, 148, 3732, 820, 3508, 92, 3676, 988, 3452, 169, 3753, 770, 3458, 98, 3682, 994, 3402, 154, 3738, 826, 3514, 81, 3665, 977, 3441, 165, 3749, 781, 3469, 109, 3693, 1005, 3398,
2838, 1942, 2166, 1270, 3062, 1886, 2187, 1067, 2859, 1963, 2112, 1216, 3008, 1888, 2224, 1048, 2840, 1944, 2168, 1272, 3064, 1875, 2183, 1063, 2855, 1959, 2127, 1231, 3023, 1903, 2239, 1044, 2836, 1940, 2164, 1268, 3060, 1884, 2185, 1065, 2857, 1961, 2114, 1218, 3010, 1890, 2226, 1050, 2842, 1946, 2170, 1274, 3066, 1873, 2181, 1061, 2853, 1957, 2125, 1229, 3021, 1901, 2237, 1046,
598, 3286, 374, 3958, 675, 3083, 395, 3979, 619, 3307, 320, 3904, 656, 3120, 432, 4016, 600, 3288, 376, 3960, 684, 3079, 391, 3975, 615, 3303, 335, 3919, 671, 3135, 447, 4031, 596, 3284, 372, 3956, 673, 3081, 393, 3977, 617, 3305, 322, 3906, 658, 3122, 434, 4018, 602, 3290, 378, 3962, 686, 3077, 389, 3973, 613, 3301, 333, 3917, 669, 3133, 445, 4029,
2390, 1494, 2691, 1571, 2467, 1291, 2635, 1739, 2411, 1515, 2747, 1552, 2448, 1328, 2672, 1776, 2392, 1496, 2700, 1580, 2476, 1287, 2631, 1735, 2407, 1511, 2743, 1567, 2463, 1343, 2687, 1791, 2388, 1492, 2689, 1569, 2465, 1289, 2633, 1737, 2409, 1513, 2745, 1554, 2450, 1330, 2674, 1778, 2394, 1498, 2702, 1582, 2478, 1285, 2629, 1733, 2405, 1509, 2741, 1565, 2461, 1341, 2685, 1789,
3, 3587, 899, 3363, 227, 3811, 843, 3531, 59, 3643, 955, 3344, 208, 3792, 880, 3568, 12, 3596, 908, 3372, 236, 3820, 839, 3527, 55, 3639, 951, 3359, 223, 3807, 895, 3583, 1, 3585, 897, 3361, 225, 3809, 841, 3529, 57, 3641, 953, 3346, 210, 3794, 882, 3570, 14, 3598, 910, 3374, 238, 3822, 837, 3525, 53, 3637, 949, 3357, 221, 3805, 893, 3581,
2984, 1795, 2243, 1123, 2915, 2019, 2075, 1179, 2971, 1851, 2299, 1104, 2896, 2000, 2084, 1188, 2980, 1804, 2252, 1132, 2924, 2028, 2071, 1175, 2967, 1847, 2295, 1119, 2911, 2015, 2090, 1194, 2986, 1793, 2241, 1121, 2913, 2017, 2073, 1177, 2969, 1849, 2297, 1106, 2898, 2002, 2086, 1190, 2982, 1806, 2254, 1134, 2926, 2030, 2069, 1173, 2965, 1845, 2293, 1117, 2909, 2013, 2088, 1192,
744, 3139, 451, 4035, 563, 3251, 283, 3867, 731, 3195, 507, 4091, 516, 3204, 292, 3876, 740, 3148, 460, 4044, 572, 3260, 279, 3863, 727, 3191, 503, 4087, 522, 3210, 298, 3882, 746, 3137, 449, 4033, 561, 3249, 281, 3865, 729, 3193, 505, 4089, 518, 3206, 294, 3878, 742, 3150, 462, 4046, 574, 3262, 277, 3861, 725, 3189, 501, 4085, 520, 3208, 296, 3880,
2536, 1347, 2579, 1683, 2355, 1459, 2803, 1627, 2523, 1403, 2607, 1711, 2308, 1412, 2756, 1636, 2532, 1356, 2588, 1692, 2364, 1468, 2812, 1623, 2519, 1399, 2594, 1698, 2314, 1418, 2762, 1642, 2538, 1345, 2577, 1681, 2353, 1457, 2801, 1625, 2521, 1401, 2605, 1709, 2310, 1414, 2758, 1638, 2534, 1358, 2590, 1694, 2366, 1470, 2814, 1621, 2517, 1397, 2592, 1696, 2312, 1416, 2760, 1640,
184, 3768, 787, 3475, 115, 3699, 1011, 3419, 143, 3727, 815, 3503, 68, 3652, 964, 3428, 180, 3764, 796, 3484, 124, 3708, 1020, 3415, 130, 3714, 802, 3490, 74, 3658, 970, 3434, 186, 3770, 785, 3473, 113, 3697, 1009, 3417, 141, 3725, 813, 3501, 70, 3654, 966, 3430, 182, 3766, 798, 3486, 126, 3710, 1022, 3413, 128, 3712, 800, 3488, 72, 3656, 968, 3432,
2872, 1976, 2131, 1235, 3027, 1907, 2215, 1039, 2831, 1935, 2159, 1263, 3055, 1860, 2196, 1076, 2868, 1972, 2140, 1244, 3036, 1916, 2217, 1026, 2818, 1922, 2146, 1250, 3042, 1866, 2202, 1082, 2874, 1978, 2129, 1233, 3025, 1905, 2213, 1037, 2829, 1933, 2157, 1261, 3053, 1862, 2198, 1078, 2870, 1974, 2142, 1246, 3038, 1918, 2219, 1024, 2816, 1920, 2144, 1248, 3040, 1864, 2200, 1080,
632, 3320, 339, 3923, 647, 3111, 423, 4007, 591, 3279, 367, 3951, 703, 3092, 404, 3988, 628, 3316, 348, 3932, 649, 3113, 425, 4009, 578, 3266, 354, 3938, 690, 3098, 410, 3994, 634, 3322, 337, 3921, 645, 3109, 421, 4005, 589, 3277, 365, 3949, 701, 3094, 406, 3990, 630, 3318, 350, 3934, 651, 3115, 427, 4011, 576, 3264, 352, 3936, 688, 3096, 408, 3992,
2424, 1528, 2732, 1543, 2439, 1319, 2663, 1767, 2383, 1487, 2719, 1599, 2495, 1300, 2644, 1748, 2420, 1524, 2721, 1545, 2441, 1321, 2665, 1769, 2370, 1474, 2706, 1586, 2482, 1306, 2650, 1754, 2426, 1530, 2734, 1541, 2437, 1317, 2661, 1765, 2381, 1485, 2717, 1597, 2493, 1302, 2646, 1750, 2422, 1526, 2723, 1547, 2443, 1323, 2667, 1771, 2368, 1472, 2704, 1584, 2480, 1304, 2648, 1752,
44, 3628, 940, 3335, 199, 3783, 871, 3559, 31, 3615, 927, 3391, 255, 3839, 852, 3540, 33, 3617, 929, 3337, 201, 3785, 873, 3561, 18, 3602, 914, 3378, 242, 3826, 858, 3546, 46, 3630, 942, 3333, 197, 3781, 869, 3557, 29, 3613, 925, 3389, 253, 3837, 854, 3542, 35, 3619, 931, 3339, 203, 3787, 875, 3563, 16, 3600, 912, 3376, 240, 3824, 856, 3544,
2956, 1836, 2284, 1095, 2887, 1991, 2103, 1207, 2999, 1823, 2271, 1151, 2943, 2047, 2049, 1153, 2945, 1825, 2273, 1097, 2889, 1993, 2105, 1209, 3001, 1810, 2258, 1138, 2930, 2034, 2062, 1166, 2958, 1838, 2286, 1093, 2885, 1989, 2101, 1205, 2997, 1821, 2269, 1149, 2941, 2045, 2051, 1155, 2947, 1827, 2275, 1099, 2891, 1995, 2107, 1211, 3003, 1808, 2256, 1136, 2928, 2032, 2060, 1164,
716, 3180, 492, 4076, 535, 3223, 311, 3895, 759, 3167, 479, 4063, 554, 3242, 257, 3841, 705, 3169, 481, 4065, 537, 3225, 313, 3897, 761, 3154, 466, 4050, 550, 3238, 270, 3854, 718, 3182, 494, 4078, 533, 3221, 309, 3893, 757, 3165, 477, 4061, 552, 3240, 259, 3843, 707, 3171, 483, 4067, 539, 3227, 315, 3899, 763, 3152, 464, 4048, 548, 3236, 268, 3852,
2508, 1388, 2620, 1724, 2327, 1431, 2775, 1655, 2551, 1375, 2570, 1674, 2346, 1450, 2794, 1601, 2497, 1377, 2609, 1713, 2329, 1433, 2777, 1657, 2553, 1362, 2566, 1670, 2342, 1446, 2790, 1614, 2510, 1390, 2622, 1726, 2325, 1429, 2773, 1653, 2549, 1373, 2568, 1672, 2344, 1448, 2792, 1603, 2499, 1379, 2611, 1715, 2331, 1435, 2779, 1659, 2555, 1360, 2564, 1668, 2340, 1444, 2788, 1612,
156, 3740, 828, 3516, 87, 3671, 983, 3447, 162, 3746, 778, 3466, 106, 3690, 1002, 3393, 145, 3729, 817, 3505, 89, 3673, 985, 3449, 173, 3757, 774, 3462, 102, 3686, 998, 3406, 158, 3742, 830, 3518, 85, 3669, 981, 3445, 160, 3744, 776, 3464, 104, 3688, 1000, 3395, 147, 3731, 819, 3507, 91, 3675, 987, 3451, 175, 3759, 772, 3460, 100, 3684, 996, 3404,
2844, 1948, 2172, 1276, 3068, 1879, 2178, 1058, 2850, 1954, 2122, 1226, 3018, 1898, 2234, 1041, 2833, 1937, 2161, 1265, 3057, 1881, 2189, 1069, 2861, 1965, 2118, 1222, 3014, 1894, 2230, 1054, 2846, 1950, 2174, 1278, 3070, 1877, 2176, 1056, 2848, 1952, 2120, 1224, 3016, 1896, 2232, 1043, 2835, 1939, 2163, 1267, 3059, 1883, 2191, 1071, 2863, 1967, 2116, 1220, 3012, 1892, 2228, 1052,
604, 3292, 380, 3964, 681, 3074, 386, 3970, 610, 3298, 330, 3914, 666, 3130, 442, 4026, 593, 3281, 369, 3953, 677, 3085, 397, 3981, 621, 3309, 326, 3910, 662, 3126, 438, 4022, 606, 3294, 382, 3966, 683, 3072, 384, 3968, 608, 3296, 328, 3912, 664, 3128, 440, 4024, 595, 3283, 371, 3955, 679, 3087, 399, 3983, 623, 3311, 324, 3908, 660, 3124, 436, 4020,
2396, 1500, 2697, 1577, 2473, 1282, 2626, 1730, 2402, 1506, 2738, 1562, 2458, 1338, 2682, 1786, 2385, 1489, 2693, 1573, 2469, 1293, 2637, 1741, 2413, 1517, 2749, 1558, 2454, 1334, 2678, 1782, 2398, 1502, 2699, 1579, 2475, 1280, 2624, 1728, 2400, 1504, 2736, 1560, 2456, 1336, 2680, 1784, 2387, 1491, 2695, 1575, 2471, 1295, 2639, 1743, 2415, 1519, 2751, 1556, 2452, 1332, 2676, 1780,
9, 3593, 905, 3369, 233, 3817, 834, 3522, 50, 3634, 946, 3354, 218, 3802, 890, 3578, 5, 3589, 901, 3365, 229, 3813, 845, 3533, 61, 3645, 957, 3350, 214, 3798, 886, 3574, 11, 3595, 907, 3371, 235, 3819, 832, 3520, 48, 3632, 944, 3352, 216, 3800, 888, 3576, 7, 3591, 903, 3367, 231, 3815, 847, 3535, 63, 3647, 959, 3348, 212, 3796, 884, 3572,
2977, 1801, 2249, 1129, 2921, 2025, 2066, 1170, 2962, 1842, 2290, 1114, 2906, 2010, 2094, 1198, 2990, 1797, 2245, 1125, 2917, 2021, 2077, 1181, 2973, 1853, 2301, 1110, 2902, 2006, 2083, 1187, 2979, 1803, 2251, 1131, 2923, 2027, 2064, 1168, 2960, 1840, 2288, 1112, 2904, 2008, 2092, 1196, 2988, 1799, 2247, 1127, 2919, 2023, 2079, 1183, 2975, 1855, 2303, 1108, 2900, 2004, 2081, 1185,
737, 3145, 457, 4041, 569, 3257, 274, 3858, 722, 3186, 498, 4082, 526, 3214, 302, 3886, 750, 3141, 453, 4037, 565, 3253, 285, 3869, 733, 3197, 509, 4093, 515, 3203, 291, 3875, 739, 3147, 459, 4043, 571, 3259, 272, 3856, 720, 3184, 496, 4080, 524, 3212, 300, 3884, 748, 3143, 455, 4039, 567, 3255, 287, 3871, 735, 3199, 511, 4095, 513, 3201, 289, 3873,
2529, 1353, 2585, 1689, 2361, 1465, 2809, 1618, 2514, 1394, 2598, 1702, 2318, 1422, 2766, 1646, 2542, 1349, 2581, 1685, 2357, 1461, 2805, 1629, 2525, 1405, 2600, 1704, 2307, 1411, 2755, 1635, 2531, 1355, 2587, 1691, 2363, 1467, 2811, 1616, 2512, 1392, 2596, 1700, 2316, 1420, 2764, 1644, 2540, 1351, 2583, 1687, 2359, 1463, 2807, 1631, 2527, 1407, 2602, 1706, 2305, 1409, 2753, 1633,
177, 3761, 793, 3481, 121, 3705, 1017, 3410, 134, 3718, 806, 3494, 78, 3662, 974, 3438, 190, 3774, 789, 3477, 117, 3701, 1013, 3421, 136, 3720, 808, 3496, 67, 3651, 963, 3427, 179, 3763, 795, 3483, 123, 3707, 1019, 3408, 132, 3716, 804, 3492, 76, 3660, 972, 3436, 188, 3772, 791, 3479, 119, 3703, 1015, 3423, 138, 3722, 810, 3498, 65, 3649, 961, 3425,
2865, 1969, 2137, 1241, 3033, 1913, 2221, 1030, 2822, 1926, 2150, 1254, 3046, 1870, 2206, 1086, 2878, 1982, 2133, 1237, 3029, 1909, 2208, 1032, 2824, 1928, 2152, 1256, 3048, 1859, 2195, 1075, 2867, 1971, 2139, 1243, 3035, 1915, 2223, 1028, 2820, 1924, 2148, 1252, 3044, 1868, 2204, 1084, 2876, 1980, 2135, 1239, 3031, 1911, 2210, 1034, 2826, 1930, 2154, 1258, 3050, 1857, 2193, 1073,
625, 3313, 345, 3929, 653, 3117, 429, 4013, 582, 3270, 358, 3942, 694, 3102, 414, 3998, 638, 3326, 341, 3925, 640, 3104, 416, 4000, 584, 3272, 360, 3944, 696, 3091, 403, 3987, 627, 3315, 347, 3931, 655, 3119, 431, 4015, 580, 3268, 356, 3940, 692, 3100, 412, 3996, 636, 3324, 343, 3927, 642, 3106, 418, 4002, 586, 3274, 362, 3946, 698, 3089, 401, 3985,
2417, 1521, 2725, 1549, 2445, 1325, 2669, 1773, 2374, 1478, 2710, 1590, 2486, 1310, 2654, 1758, 2430, 1534, 2731, 1536, 2432, 1312, 2656, 1760, 2376, 1480, 2712, 1592, 2488, 1299, 2643, 1747, 2419, 1523, 2727, 1551, 2447, 1327, 2671, 1775, 2372, 1476, 2708, 1588, 2484, 1308, 2652, 1756, 2428, 1532, 2729, 1538, 2434, 1314, 2658, 1762, 2378, 1482, 2714, 1594, 2490, 1297, 2641, 1745,
37, 3621, 933, 3341, 205, 3789, 877, 3565, 22, 3606, 918, 3382, 246, 3830, 862, 3550, 43, 3627, 939, 3328, 192, 3776, 864, 3552, 24, 3608, 920, 3384, 248, 3832, 851, 3539, 39, 3623, 935, 3343, 207, 3791, 879, 3567, 20, 3604, 916, 3380, 244, 3828, 860, 3548, 41, 3625, 937, 3330, 194, 3778, 866, 3554, 26, 3610, 922, 3386, 250, 3834, 849, 3537,
2949, 1829, 2277, 1101, 2893, 1997, 2109, 1213, 3005, 1814, 2262, 1142, 2934, 2038, 2059, 1163, 2955, 1835, 2283, 1088, 2880, 1984, 2096, 1200, 2992, 1816, 2264, 1144, 2936, 2040, 2055, 1159, 2951, 1831, 2279, 1103, 2895, 1999, 2111, 1215, 3007, 1812, 2260, 1140, 2932, 2036, 2057, 1161, 2953, 1833, 2281, 1090, 2882, 1986, 2098, 1202, 2994, 1818, 2266, 1146, 2938, 2042, 2053, 1157,
709, 3173, 485, 4069, 541, 3229, 317, 3901, 765, 3158, 470, 4054, 547, 3235, 267, 3851, 715, 3179, 491, 4075, 528, 3216, 304, 3888, 752, 3160, 472, 4056, 556, 3244, 263, 3847, 711, 3175, 487, 4071, 543, 3231, 319, 3903, 767, 3156, 468, 4052, 545, 3233, 265, 3849, 713, 3177, 489, 4073, 530, 3218, 306, 3890, 754, 3162, 474, 4058, 558, 3246, 261, 3845,
2501, 1381, 2613, 1717, 2333, 1437, 2781, 1661, 2557, 1366, 2563, 1667, 2339, 1443, 2787, 1611, 2507, 1387, 2619, 1723, 2320, 1424, 2768, 1648, 2544, 1368, 2572, 1676, 2348, 1452, 2796, 1607, 2503, 1383, 2615, 1719, 2335, 1439, 2783, 1663, 2559, 1364, 2561, 1665, 2337, 1441, 2785, 1609, 2505, 1385, 2617, 1721, 2322, 1426, 2770, 1650, 2546, 1370, 2574, 1678, 2350, 1454, 2798, 1605,
149, 3733, 821, 3509, 93, 3677, 989, 3453, 168, 3752, 771, 3459, 99, 3683, 995, 3403, 155, 3739, 827, 3515, 80, 3664, 976, 3440, 164, 3748, 780, 3468, 108, 3692, 1004, 3399, 151, 3735, 823, 3511, 95, 3679, 991, 3455, 170, 3754, 769, 3457, 97, 3681, 993, 3401, 153, 3737, 825, 3513, 82, 3666, 978, 3442, 166, 3750, 782, 3470, 110, 3694, 1006, 3397,
2837, 1941, 2165, 1269, 3061, 1885, 2184, 1064, 2856, 1960, 2115, 1219, 3011, 1891, 2227, 1051, 2843, 1947, 2171, 1275, 3067, 1872, 2180, 1060, 2852, 1956, 2124, 1228, 3020, 1900, 2236, 1047, 2839, 1943, 2167, 1271, 3063, 1887, 2186, 1066, 2858, 1962, 2113, 1217, 3009, 1889, 2225, 1049, 2841, 1945, 2169, 1273, 3065, 1874, 2182, 1062, 2854, 1958, 2126, 1230, 3022, 1902, 2238, 1045,
597, 3285, 373, 3957, 672, 3080, 392, 3976, 616, 3304, 323, 3907, 659, 3123, 435, 4019, 603, 3291, 379, 3963, 687, 3076, 388, 3972, 612, 3300, 332, 3916, 668, 3132, 444, 4028, 599, 3287, 375, 3959, 674, 3082, 394, 3978, 618, 3306, 321, 3905, 657, 3121, 433, 4017, 601, 3289, 377, 3961, 685, 3078, 390, 3974, 614, 3302, 334, 3918, 670, 3134, 446, 4030,
2389, 1493, 2688, 1568, 2464, 1288, 2632, 1736, 2408, 1512, 2744, 1555, 2451, 1331, 2675, 1779, 2395, 1499, 2703, 1583, 2479, 1284, 2628, 1732, 2404, 1508, 2740, 1564, 2460, 1340, 2684, 1788, 2391, 1495, 2690, 1570, 2466, 1290, 2634, 1738, 2410, 1514, 2746, 1553, 2449, 1329, 2673, 1777, 2393, 1497, 2701, 1581, 2477, 1286, 2630, 1734, 2406, 1510, 2742, 1566, 2462, 1342, 2686, 1790
};
private void ComputeBayerMatrix() {
// 0x55555555 = 0101 0101 0101 0101…
uint o = 0x55555555;
uint _x = 0;
uint _y = 0;
uint _size = 64;
indices = new uint[_size, _size];
for (uint i = 0; i <= _size * _size; ++i) {
uint c = (uint)(i & -i);
_x += _size / 2;
_y += _size / 2;
switch (c) {
case 0: _x -= _size / 2; _y -= _size / 2; break;
case 2: _x += _size / (2 * c / 2); break;
case 4: _x += _size / (2 * c / 2); _y += _size / (2 * c / 2); break;
case 8: _x += _size / (2 * c / 4); break;
case 16: _x += _size / (2 * c / 4); _y += _size / (2 * c / 4); break;
case 32: _x += _size / (2 * c / 8); break;
case 64: _x += _size / (2 * c / 8); _y += _size / (2 * c / 8); break;
case 128: _x += _size / (2 * c / 16); break;
case 256: _x += _size / (2 * c / 16); _y += _size / (2 * c / 16); break;
case 512: _x += _size / (2 * c / 32); break;
case 1024: _x += _size / (2 * c / 32); _y += _size / (2 * c / 32); break;
case 2048: _x += _size / (2 * c / 64); break;
case 4096: _x += _size / (2 * c / 64); _y += _size / (2 * c / 64); break;
}
indices[_x % _size, _y % _size] = i;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment