uniform vec2 resolution; uniform sampler2D u_texture; float mod(float x, float y) { return x-y * floor(x/y); } float get(vec2 p) { vec2 pos = p / resolution; return texture2D(u_texture, pos).g; } void main(void) { float in_c = get(gl_FragCoord.xy); float out_c = 0.0; float count = 0.0; for (float x = -1.0; x < 2.0; x++) { for (float y = -1.0; y < 2.0; y++) { if (x == 0.0 && y == 0.0) continue; count += get( vec2(mod(gl_FragCoord.x+x, resolution.x), mod(gl_FragCoord.y+y, resolution.y )) ) > 0.6?1.0:0.0; } } if (in_c > 0.6) if (count == 2.0 || count == 3.0) out_c = 1.0; else out_c = 0.5; else if (count == 3.0) out_c = 1.0; else out_c = in_c<0.05?0.0:in_c*0.95; gl_FragColor = vec4(0.1*out_c, out_c, 0.5*out_c, 1.0); }