Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const vec3 luma = vec3(0.2126, 0.7152, 0.0722);
float round(float a){
return floor(a + .5);
}
float dither (vec2 fragCoord) {
float size = 3.0;
return texture(iChannel1, fract(fragCoord / vec2(8.0*size,8.0*size))).r;
}
float quantize (float col, float steps) {
return round(col * steps) / steps;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord/iResolution.xy;
// Time varying pixel color
//vec3 col = 0.5 + 0.5*cos(iTime+uv.xyx+vec3(0,2,4));
vec3 col = texture(iChannel0, uv).rgb;
float lumi = dot(luma, col);
float steps = 2.0;
float c = quantize(lumi + dither(fragCoord) / steps, steps);
fragColor = vec4(c,c,c, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment