float bayer2(in vec2 coord){
    coord = floor(coord);
    return fract( dot(coord, vec2(0.5, coord.y * 0.75)) );
}

#define bayer4(coord)   (bayer2( 0.5*(coord))*0.25+bayer2(coord))
#define bayer8(coord)   (bayer4( 0.5*(coord))*0.25+bayer2(coord))
#define bayer16(coord)  (bayer8( 0.5*(coord))*0.25+bayer2(coord))
#define bayer32(coord)  (bayer16(0.5*(coord))*0.25+bayer2(coord))
#define bayer64(coord)  (bayer32(0.5*(coord))*0.25+bayer2(coord))
#define bayer128(coord)  (bayer64(0.5*(coord))*0.25+bayer2(coord))

void pcg(inout uint seed) { //noise by https://www.pcg-random.org/
    uint state = seed * 747796405u + 2891336453u;
    uint word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
    seed = (word >> 22u) ^ word;
}

uint rngState = uint(viewWidth * viewHeight) * uint(frameCounter) + uint(gl_FragCoord.x + gl_FragCoord.y * viewWidth);
float randF() { pcg(rngState); return float(rngState) / float(0xffffffffu); }
