Screen Melt Shader - Anton Gerdelan
#version 300 es // "Screen Melt" vertex shader. GLSL. // by Anton Gerdelan Dec. 2021 in vec4 a_pos; out vec2 v_st; void main() { v_st = a_pos.xy * 0.5 + 0.5; v_st.t = 1.0 - v_st.t; gl_Position = vec4( a_pos.xy, 0.0, 1.0 ); }
#version 300 es // "Screen Melt" fragment shader. GLSL. // by Anton Gerdelan Dec. 2021 precision highp float; in vec2 v_st; uniform float u_time; uniform sampler2D u_texture; out vec4 o_frag_colour; float rand_delay() { float w = 1280.0; float f = gl_FragCoord.x / 1280.0; float n_snakes = 160.0; // i think it was 2 pixel wide on a 320px float column = floor( n_snakes * f ); float max_delay = 0.45; // this is terrible but it might work float r = clamp( sin( column * 5.5 * cos( column * 0.16) * 0.32124 ) * 0.5 + 0.5, 0.0, 1.0 ) * max_delay; return r; } void main() { float effect_time = 2.0; float r = rand_delay(); float t = mod( u_time, effect_time ); vec2 st = vec2( v_st.s, v_st.t ); if ( t > r * 1.0 ) { st.t -= (t - r ) ; } vec4 texel = texture( u_texture, st ); o_frag_colour = texel; //o_frag_colour * 0.25 + texel * 0.75; if ( st.t < 0.0 || st.t > 1.0 ) { o_frag_colour = vec4( 0.0, 0.0, 0.0, 1.0 ); } // visualise the effect time: //o_frag_colour = vec4( 0.0, t / effect_time , 0.0, 1.0 ); // visualise the column delays: //o_frag_colour = vec4( rand_delay(), 0.0 , 0.0, 1.0 ); }