Created
April 29, 2020 18:21
-
-
Save JuriaanGregor/719c6290939646f9cc36903a11f80760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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