varying vec2 texcoord;
uniform sampler2DRect map;

uniform float radius;

uniform float centerx;
uniform float centery;


void main (void)
{
/* whirl dots

float spacing=0.0;

float angle=3.0;
radius=5.0;
	vec4 fillColor,sink;
		vec2 xy0 = texcoord;
		vec2 xy1 = xy0;
		
		// aabb of dot with spacing
		float rs = radius * 2.0 + spacing;
		
		// shift into square
		xy1 -= mod( xy1, vec2(rs, rs) );
		
		// put into the middle
		xy1 += vec2(radius);
		
		if (length(xy0 - xy1) > radius) sink = fillColor;
		else
		{
			vec2 center = xy1;
			vec2 delta  = xy0 - center;
			
			float d = length(delta);
			float r = radius;
			float phi = atan(delta.y, delta.x) + angle * (r - d) / r;
			
			xy1 = center + float2(d * cos(phi), d * sin(phi));
			
			vec4 c0 = texture2DRect(map, xy0);
			vec4 c1 = texture2DRect(map, xy1);
			
			sink = (d < r)? c1: c0;
		}

 gl_FragColor =sink;
 
*/
 // fisheye
    vec2 center;
    center.x = centerx;
    center.y = centery;

    vec2 pos  = texcoord - center;
    float step  = length(pos) / radius;

    step *= 1.0;
    pos *= step;

	vec4 col= texture2DRect(map, center +pos );
    //pxl = sampleLinear( src, center + pos );
    gl_FragColor =col;


	/*	vec2 texcoord0 = texcoord;

	vec4 col= texture2DRect(map, texcoord0 );
	col.r=1.0;
	gl_FragColor =col;
	*/

	 
}
