uniform sampler2D texture1;
uniform sampler2D texture2;
uniform float time = 1.0;
uniform float flip = 1.0;
uniform float distort = 1.0;
void main()
{


	vec2 p = vec2((gl_TexCoord[0].s*256/128)-1,(gl_TexCoord[0].t*256/128)-1);
 
	    // angle of each pixel to the center of the screen
    float a = atan(p.y,-p.x);

  float e = distort;
    float r = pow( pow(p.x*p.x,e) + pow(p.y*p.y,e), 1.0/(2.*e) );
    
    // index texture by (animated inverse) radious and angle
    vec2 uv = vec2( 0.3/(r+e) + 0.2*time, a/3.1415927 );

        // naive fecth color
        vec3 col = texture2D( texture2, uv ).xyz;
	
    
    // darken at the center    
    col = col*r;
    
	gl_FragColor = vec4(col,1.0);
}