// My custom shader for implementing dithered alpha shader_type canvas_item; uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; void fragment() { // Fancy dithered alpha stuff vec4 color = texture(screen_texture, SCREEN_UV); float opacity = color.r; int x = int(FRAGCOORD.x) % 4; int y = int(FRAGCOORD.y) % 4; int index = x + y * 4; float limit = 0.0; if (x < 8) { if (index == 0) limit = 0.0625; if (index == 1) limit = 0.5625; if (index == 2) limit = 0.1875; if (index == 3) limit = 0.6875; if (index == 4) limit = 0.8125; if (index == 5) limit = 0.3125; if (index == 6) limit = 0.9375; if (index == 7) limit = 0.4375; if (index == 8) limit = 0.25; if (index == 9) limit = 0.75; if (index == 10) limit = 0.125; if (index == 11) limit = 0.625; if (index == 12) limit = 1.0; if (index == 13) limit = 0.5; if (index == 14) limit = 0.875; if (index == 15) limit = 0.375; } // Is this pixel below the opacity limit? Skip drawing it COLOR = mix(vec4(0,0,0,0), vec4(1,1,1,color.a), step(limit, opacity)); }