!!ARBfp1.0
OPTION ARB_precision_hint_fastest;

#-----------------------------------
OUTPUT oCol = result.color;

ATTRIB tc0 = fragment.texcoord[0];
ATTRIB tc1 = fragment.texcoord[1];

PARAM p0 = program.env[0];
#PARAM p1 = program.env[1];

PARAM c0 = { 0, 2, 4, 6 };
PARAM c1 = { 8, 12, 16, 20 };
PARAM c2 = { 0.125, 0.5, 2, 0 };

TEMP r0;
TEMP r1;
TEMP r2;
TEMP r3;
TEMP r4;
TEMP r5;
TEMP r6;
TEMP r7;

TEMP t0;
TEMP t1;

# Calculate screen coordinate
RCP t1.w, tc1.w;
MUL t1, tc1, t1.w;
MAD t1, t1, p0.xyxy, c2.yyww;

# Get direction
MUL t0, tc0, p0;
SUB t0, t0, t1;
MUL t0, t0, p0;

# Find sample positions
MAD r0, t0, c0.x, t1;
MAD r1, t0, c0.y, t1;
MAD r2, t0, c0.z, t1;
MAD r3, t0, c0.w, t1;
MAD r4, t0, c1.x, t1;
MAD r5, t0, c1.y, t1;
MAD r6, t0, c1.z, t1;
MAD r7, t0, c1.w, t1;

# Fetch colors
TEX r0, r0, texture[0], 2D;
TEX r1, r1, texture[0], 2D;
TEX r2, r2, texture[0], 2D;
TEX r3, r3, texture[0], 2D;
TEX r4, r4, texture[0], 2D;
TEX r5, r5, texture[0], 2D;
TEX r6, r6, texture[0], 2D;
TEX r7, r7, texture[0], 2D;

# Calculate final color
MAD r0, r0, -1, r1;
ADD r1, r2, r3;
ADD r2, r4, r5;
ADD r3, r6, r7;
ADD r0, r0, r1;
ADD r1, r2, r3;
ADD r0.rgb, r0, r1;
ADD_SAT r0.a, r0.a, r1.a;

LRP r0, r0.a, r0, 1;

MOV oCol, r0;


END
