
struct fragment {
	float4 position  : POSITION;
	float2 texcoord0 : TEXCOORD0;
};

float4 main(float2 texcoord : TEXCOORD0,
			uniform sampler2D texture,
			uniform sampler2D texture2,
			uniform float bri,
			uniform float intensity,
			uniform float fade,
			uniform float zoom,
			uniform float xmul,
			uniform float ymul) : COLOR0
{
/*	float2 paskamul = float2(xmul, ymul);
	float2 texnew1 = texcoord*paskamul;*/
	float2 texnew1 = texcoord;
	float3 col = tex2D(texture, texcoord).rgb;
	float3 origcol = col;
	float2 texvec = (texnew1*2.0-1.0)*intensity;
	float3 dvec = (-0.5+0.5*tex2D(texture2, texcoord).rgb);
	texnew1.x += texvec.x*dvec.x*0.5*zoom;
	texnew1.y += texvec.y*dvec.z*0.5*zoom;
	float4 newcol = tex2D(texture, texnew1.xy)*0.75 + zoom*tex2D(texture, texnew1.yx*0.025)*0.25;
	col = newcol.rgb;
	float dlen = length(dvec);
	dlen = dlen*(1.0-bri*0.8);
	float brimul = 1.0*(1.0-dlen);
	return float4(fade*col*brimul + (1-fade)*origcol*brimul, 1.0);
}