######################################################
######################################################

!!ARBvp1.0 OPTION ARB_position_invariant;

# basic texcoord
MOV 	result.texcoord[0], vertex.texcoord[0];

END;

######################################################
######################################################

!!ARBfp1.0 
OPTION ARB_precision_hint_nicest;

###

PARAM	xero = { 0.0, 0.0, 0.0 };

PARAM	offs1 = { -1, -1 };
PARAM	offs2 = { 1, -1 };
PARAM	offs3 = { -1, 1 };
PARAM	offs4 = { 1, 1 };

PARAM	offs5 = { -1, 0 };
PARAM	offs6 = { 1, 0 };
PARAM	offs7 = { 0, -1 };
PARAM	offs8 = { 0, 1 };

PARAM	offs9 = { -2, -2 };
PARAM	offs0 = { 2, 2 };
PARAM	offsA = { 2, -2 };
PARAM	offsB = { -2, 2 };


# weights
PARAM	w1 = { 0.021, 0.021, 0.021 };	# corners
PARAM	w2 = { 0.042, 0.042, 0.042 };	# left & top
PARAM	w3 = { 0.2, 0.2, 0.2 };	# far (offs9+)

###

TEMP R1, R2, S1, S2, S3, W, offs;

### 

MUL	offs, program.env[1], offs1;
ADD	R1, fragment.texcoord[0], offs;
TEX	R2, R1, texture[0], 2D;

MUL	offs, program.env[1], offs2;
ADD	R1, fragment.texcoord[0], offs;
TEX	R1, R1, texture[0], 2D;
ADD	R2, R2, R1;

MUL	offs, program.env[1], offs3;
ADD	R1, fragment.texcoord[0], offs;
TEX	R1, R1, texture[0], 2D;
ADD	R2, R2, R1;

MUL	offs, program.env[1], offs4;
ADD	R1, fragment.texcoord[0], offs;
TEX	R1, R1, texture[0], 2D;
ADD	S1, R2, R1;

###

MUL	offs, program.env[1], offs5;
ADD	R1, fragment.texcoord[0], offs;
TEX	R2, R1, texture[0], 2D;

MUL	offs, program.env[1], offs6;
ADD	R1, fragment.texcoord[0], offs;
TEX	R1, R1, texture[0], 2D;
ADD	R2, R2, R1;

MUL	offs, program.env[1], offs7;
ADD	R1, fragment.texcoord[0], offs;
TEX	R1, R1, texture[0], 2D;
ADD	R2, R2, R1;

MUL	offs, program.env[1], offs8;
ADD	R1, fragment.texcoord[0], offs;
TEX	R1, R1, texture[0], 2D;
ADD	S2, R2, R1;

###

MUL	offs, program.env[1], offs9;
ADD	R1, fragment.texcoord[0], offs;
TEX	R2, R1, texture[0], 2D;

MUL	offs, program.env[1], offs0;
ADD	R1, fragment.texcoord[0], offs;
TEX	R1, R1, texture[0], 2D;
ADD	R2, R2, R1;

MUL	offs, program.env[1], offsA;
ADD	R1, fragment.texcoord[0], offs;
TEX	R1, R1, texture[0], 2D;
ADD	R2, R2, R1;

MUL	offs, program.env[1], offsB;
ADD	R1, fragment.texcoord[0], offs;
TEX	R1, R1, texture[0], 2D;
ADD	S3, R2, R1;

### weighin

TEX	W, xero, texture[1], 2D;
MUL	W, W, 0.5;
ADD	W, W, 0.515;

### 

MUL	S1, S1, w1;
MUL	S2, S2, w2;
MUL	S3, S3, w3;

ADD	R1, S1, S2;
ADD	R2, R1, S3;

MUL	result.color.xyz, R2, W;

###

END;
