uniform float lx, ly;
uniform sampler2D htex, ltex;

const float d = 0.002;
const vec4 lgt = vec4(1.0, 1.0, 1.0, 1.0);

void main()
{
	vec2 tc = gl_TexCoord[0].st;
	vec2 ttc = vec2(tc);
	ttc = ttc - vec2(0.5, 0.5);
	ttc = ttc * 128;

	vec4 gfx = texture2D(htex, tc);

	tc.s = tc.s - d;
	float cl = texture2D(htex, tc).a;

	tc.s = tc.s + 2.0 * d;
	float cr = texture2D(htex, tc).a;

	tc.s = tc.s - d;
	tc.t = tc.t + d;
	float cu = texture2D(htex, tc).a;

	tc.t = tc.t - 2.0 * d;
	float cd = texture2D(htex, tc).a;

	float dx = (cr - cl) * 0.75;
	float dy = (cu - cd) * 0.75;

	tc.s = tc.s + dx + lx;
	tc.t = tc.t + dy + ly;
	
	float c = 16.0 / distance(vec2(ttc.s + (lx + dx) * 256.0, ttc.t + (ly + dy) * 256.0), vec2(0.0, 0.0));
	


//	float c = texture2D(ltex, tc).a;

	gfx = mix(gfx, lgt, c);
	// eikona stuff: final_color = img_color * c;

	gl_FragColor = gfx;
}
