1 #version 330 core 2 3 uniform float time; 4 uniform vec2 resolution; 5 uniform sampler2D image; 6 7 in vec2 out_uv; 8 9 vec3 hsl2rgb(vec3 c) { 10 vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0); 11 return c.z + c.y * (rgb-0.5)*(1.0-abs(2.0*c.z-1.0)); 12 } 13 14 void main() { 15 vec4 tc = texture(image, out_uv); 16 float d = tc.r; 17 float aaf = fwidth(d); 18 float alpha = smoothstep(0.5 - aaf, 0.5 + aaf, d); 19 vec2 frag_uv = gl_FragCoord.xy / resolution; 20 vec4 rainbow = vec4(hsl2rgb(vec3((time + frag_uv.x + frag_uv.y), 0.5, 0.5)), 1.0); 21 gl_FragColor = vec4(rainbow.rgb, alpha); 22 }
