shader_type canvas_item; //uniform sampler2D origin; uniform sampler2D noise; uniform vec2 tiling; uniform vec2 extraoffset; uniform bool isON=true; void fragment() { vec2 c = vec2(FRAGCOORD.x, FRAGCOORD.y); vec2 res = vec2(1.0 / SCREEN_PIXEL_SIZE.x,1.0 / SCREEN_PIXEL_SIZE.y); vec2 u = c / res.xy, n = texture(noise, u * .1).rg; // Displacement //vec4 f = textureLod(origin, u*tiling+extraoffset, 2.5); vec4 f=texture(SCREEN_TEXTURE,SCREEN_UV*tiling+extraoffset); // Loop through the different inverse sizes of drops if (isON) { for (float r = 4. ; r > 0. ; r--) { vec2 x = res.xy * r * .015, // Number of potential drops (in a grid) p = 6.28 * u * x + (n - .5) * 2., s = sin(p); // Current drop properties. Coordinates are rounded to ensure a // consistent value among the fragment of a given drop. vec4 d = texture(noise, round(u * x - 0.25) / x); // Drop shape and fading float t = (s.x+s.y) * max(0., 1. - fract(TIME * (d.b + .1) + d.g) * 1.7); // d.r -> only x% of drops are kept on, with x depending on the size of drops if (d.r < (3.-r)*.02 && t > 0.5) { // Drop normal vec3 v = normalize(-vec3(cos(p), mix(.2, 2., t-.5))); // fragColor = vec4(v * 0.5 + 0.5, 1.0); // show normals // Poor man's refraction (no visual need to do more) f = texture(SCREEN_TEXTURE, (u - v.xy * .1)*tiling+extraoffset); if(f.r == 1.0 && f.g == 1.0 && f.b == 1.0){ f.a = 0.0 } } } } else { f=texture(SCREEN_TEXTURE,SCREEN_UV); } COLOR = f; }