uniform sampler2D tex;
uniform float disto;
uniform float distoPhase;

void main(void)
{
	
	vec2 newTCoord=vec2(gl_TexCoord[0]);
	
	//newTCoord.x-=0.5;
    //newTCoord.y-=0.5;
    float distanceFromCenterX = abs(newTCoord.x - 0.5);
    float distanceFromCenterY = abs(newTCoord.y - 0.5);

	newTCoord.y += sin(distoPhase + 4.14*distanceFromCenterX)*(disto/1000.0)*distanceFromCenterY;
	newTCoord.x += cos(distoPhase-1.0 + 4.14*distanceFromCenterY)*(disto/1000.0)*distanceFromCenterY;
	
	
	//thisTCoord.x += sin(thisTCoord.x );

    newTCoord = clamp(newTCoord,0.01,0.99);
	vec4 value = texture2D(tex,vec2(newTCoord.x,newTCoord.y));
	
	
	//we must remap the coordinates into circle-space. (polar coorinates)..

	
/*value+=texture2D(tex,vec2(newTCoord.x,newTCoord.y+0.0078125))*0.8521;
value+=texture2D(tex,vec2(newTCoord.x,newTCoord.y+0.015625))*0.5273;
value+=texture2D(tex,vec2(newTCoord.x,newTCoord.y+0.0234375))*0.2369;

value+=texture2D(tex,vec2(newTCoord.x,newTCoord.y-0.0078125))*0.8521;
value+=texture2D(tex,vec2(newTCoord.x,newTCoord.y-0.015625))*0.5273;
value+=texture2D(tex,vec2(newTCoord.x,newTCoord.y-0.0234375))*0.2369;
value/=4.23;*/

//value.r=1;
	gl_FragColor = value;
}

