xxxxxxxxxx
98
precision mediump float;
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
uniform sampler2D bufferin;
vec2 rot(vec2 _uv, float _a){
float s = sin(_a);
float c = cos(_a);
return _uv*mat2(c,-s,s,c);
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = ( (gl_FragCoord.xy -.5) / resolution.xy );
uv +=.002;
// change wobble freqency over time
float freq_one = sin(time*1.5 + uv.x*3.)*5.+6.;
float freq_two = sin(time*.75 + uv.y*3.)*5.+15.;
freq_one *=.001;
freq_two *=.002;
// wobble here
uv.x += sin(uv.y*freq_one*resolution.y + time*3.1) *.0001;
uv.y += sin(uv.x*freq_two*resolution.x + time*4.1) *.0005;
// --------------------------------------------
// mouse will be the brush
vec2 mp = mouse-uv;
mp.x *= resolution.x/resolution.y;
float lmp = length(mp )/.03 ;
// Distort away from mouse
float mdStrength = 0.015 * pow((1.0 - length(mp)), 12.0);
float mdAngle = atan(mp.y, mp.x);
uv.x += mdStrength * cos(mdAngle);
uv.y += mdStrength * sin(mdAngle);
// --------------------------------------------
// this is a forked piece of code to "rectify" the pixels a bit
float jitter = .5;
uv.x += (fract(sin(uv.x*345.3 + uv.y*423.3 + time*426.4) * 345.3)- 0.5) / resolution.x * jitter;
uv.y += (fract(sin(uv.x*234.8 + uv.y*264.8 + time*521.3) * 634.7)- 0.5) / resolution.y * jitter;
vec2 px = 1.0 / resolution ;
// uv -= 0.25 * px;
uv.y = 1. -uv.y;
// uv.x *=1.02;
// uv.y *=.995;
// still the crappier buffer read out, but it looks nice :)
vec3 col = texture2D(bufferin, uv).xyz ;
fragColor = vec4(col.rgb ,1.);
// change the brush over time
float color_change_freq = ( sin(time*.1)*.9+1. )*1.1;
float brush_color_freq = ( sin(time*2.3)*.9+1. )*6.1 ;
// oscillate thriough colors along the dist
col.x = sin(time* .32 * color_change_freq + lmp*brush_color_freq + 1.23);
col.y = sin(time*.13 * color_change_freq + lmp*brush_color_freq + 2.2234);
col.z = sin(time*.62 * color_change_freq + lmp*brush_color_freq + 5.212);
// overpaint the buffer with some new input
if (lmp < .6 ) {
fragColor += vec4( col.rgb, 1. )*.5 ;
}
//fragColor = vec4(col,1.0);
}
// --------[ Original ShaderToy ends here ]---------- //
void main(void)
{
mainImage(gl_FragColor, gl_FragCoord.xy);
}