shader_type spatial; render_mode unshaded; uniform sampler2D effect_texture; uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; uniform float time_elapsed = 0.; uniform float speed = 0.; //void vertex() { //VERTEX.y += cos(VERTEX.x * TIME *0.05)*3.1 ; //} float neighbour_alpha_accumulator(vec2 coord, float input_margin) { float acc = 0.; float margin = (1.-coord.y) * input_margin; for (float i=-margin;i<=margin;i=i+margin) { for (float j=-margin;j<=margin;j=j+margin) { vec2 new_uv = coord + vec2(i,j); float val = 0.; if (new_uv.x > 1. || new_uv.x < 0. || new_uv.y > 1. || new_uv.y < 0.) { val = 0.; } else { val = texture(effect_texture, coord + vec2(i,j)).a; } acc += val; } } float final_val = acc/9.; if (final_val >= 1.) { final_val = 0.; } else { final_val = texture(effect_texture, coord).a; } return final_val; } void fragment() { vec2 new_uv = UV; //if (new_uv.x > 1. || new_uv.x < 0. || new_uv.y > 1. || new_uv.y < 0.) { //COLOR.a = 0.; //} else { //COLOR = texture(TEXTURE, new_uv); //} ALBEDO = vec3(1.); ALPHA = neighbour_alpha_accumulator(UV, 0.1); }