uniform sampler2D colmap;
uniform float uScale;
uniform float uBias;
uniform float ghostX, ghostY;

vec4 contrast(vec2 xy) {

//	vec2 xy = gl_TexCoord[0].xy;
	vec4 col = texture2D(colmap,xy);
	vec4 res = max(vec4(0.0), col + vec4(uBias)) * vec4(uScale);
	return res;
}
	
void main( void )
{

	vec2 xy = gl_TexCoord[0].xy;
	vec4 col = vec4(0);
	int i=0;
	xy -= vec2(0.5);
	vec2 ghostvec = vec2(ghostX,ghostY);
	vec2 xy2;
	float percent;
	float dist ;
	for(i=0; i < 6; i++) {
		percent = float(i)/5;
		xy2 = ghostvec*vec2(percent-0.5);
		xy2.x += xy.x / (percent*1.0 + (1-percent)*(-1.0));
		xy2.y += xy.y / (percent*1.0 + (1-percent)*(-1.0));
	/*	xy2.x = min(xy2.x,0.5);
		xy2.y = min(xy2.y,0.5);
		xy2.x = max(xy2.x,-0.5);
		xy2.y = max(xy2.y,-0.5);*/
		xy2 += ghostvec*percent;
		dist = min(distance(vec2(0.0),xy2)*2.0,1.0);
		col += (contrast(xy2+vec2(0.5)))  *vec4(1.0-dist);
	}

/*
	for(i=0; i < 3; i++) {
		xy2.x = 0.45+float(i-2)/8;
		xy2.y = distance(xy,vec2(0));
		col += contrast(xy2)*vec4(xy2.y*0.33);
	}
	*/
/*	float a = atan(xy.y/xy.x);
	float d  = distance(vec2(0),xy.xy);
	xy2.x = sin(a)*d*d;
	xy2.y = cos(a)*d*d;
	col += contrast(xy2);*/


	//distance(xy*vec2(1.6,1),vec2(0.8,0.5))/100.0+0.5;


	
	//col += texture2D(colmap,xy);

	
	gl_FragColor = col;

}

