#ifdef GL_ES
precision highp float;
#endif
uniform vec2 resolution;
uniform float time;
uniform sampler2D tex0;
uniform sampler2D tex1;
vec3 deform( in vec2 p, float scale )
{
vec2 uv;
float mtime = scale+time;
float a = atan(p.y,p.x);
float r = sqrt(dot(p,p));
//float s = r * (1.0+0.5*cos(mtime*0.1));
float s = r * (1.0+0.03*cos(mtime*0.001)); //speed?
//uuv.x = .1*mtime +.05*p.y+.05*cos(-mtime+a*3.0)/s;
uv.x = .1*mtime +.09*p.y+.1*cos(-mtime+a*2.0)/s;
//uv.y = .1*mtime +.05*p.x+.05*sin(-mtime+a*1.0)/s;
uv.y = .1*mtime +.1*p.x+.09*sin(-mtime+a*1.0)/s; //depth
//float w = 0.8-0.2*cos(mtime+3.0*a);
float w = 0.8-0.2*cos(mtime+3.0*a);
vec3 res = texture2D(tex0,uv).xyz*w;
return res*res;
}
void main(void)
{
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
vec3 total = vec3(0.0);
float w = 0.0;
//for( int i=0; i<20; i++ )
for( int i=0; i<21; i++ )
{
vec3 res = deform(p,w);
total += res;
//w += 0.02;
w += 0.02;
}
//total /= 20.0;
total /= 100.0;
//gl_FragColor = vec4( 3.0*total,1.01);
gl_FragColor = vec4( 8.0*total,1.01);
// gl_FragColor = vec4( 1.0,0.0,0.0,1.01);
}