mirror of
https://github.com/barkeser2002/flower.git
synced 2026-09-25 15:36:14 +03:00
29 lines
616 B
GLSL
29 lines
616 B
GLSL
#ifndef BAYER_GLSL
|
|
#define BAYER_GLSL
|
|
|
|
// 4x4 bayer filter, use for cloud reconstruction.
|
|
const int bayerFilter4x4[16] = int[]
|
|
(
|
|
0, 8, 2, 10,
|
|
12, 4, 14, 6,
|
|
3, 11, 1, 9,
|
|
15, 7, 13, 5
|
|
);
|
|
|
|
// ivec2 offset = ivec2(bayerFilter4x4[frameId] % 4, bayerFilter4x4[frameId] / 4);
|
|
//
|
|
|
|
float bayerDither(float grayscale, ivec2 pixelCoord)
|
|
{
|
|
int bayerMatrix16[16] = int[16](
|
|
0, 8, 2, 10,
|
|
12, 4, 14, 6,
|
|
3, 11, 1, 9,
|
|
15, 7, 13, 5
|
|
);
|
|
|
|
int pixelIndex16 = (pixelCoord.x % 4) + (pixelCoord.y % 4) * 4;
|
|
return grayscale > (float(bayerMatrix16[pixelIndex16]) + 0.5) / 16.0 ? 1.0 : 0.0;
|
|
}
|
|
|
|
#endif |