# Nathan Ostgard
# nostgard+doom3@gmail.com

# ==============================================================================
!!ARBvp1.0 OPTION ARB_position_invariant;

PARAM	size = 0.0016;
TEMP	offset;

MOV	offset, size;
MUL	offset.y, offset.y, 1.33333;
MOV	result.texcoord[0], offset;

END


# ==============================================================================
!!ARBfp1.0 OPTION ARB_precision_hint_nicest;

# fragment size
PARAM size = { 0.0016, 0.00213333, 0, 0 };

# these are the multipliers for the gaussian blur
PARAM mu01 = 0.00261097;
PARAM mu02 = 0.00522193;
PARAM mu03 = 0.01044386;
PARAM mu04 = 0.02088773;
PARAM mu05 = 0.04177546;
PARAM mu06 = 0.08355091;
PARAM mu07 = 0.16710183;
PARAM mu08 = 0.33420366;
PARAM mu09 = 0.66840732;

# offsets (in texels) for the blur
PARAM st01 = { 0, -8, 0, 0 };
PARAM st02 = { 0, -7, 0, 0 };
PARAM st03 = { 0, -6, 0, 0 };
PARAM st04 = { 0, -5, 0, 0 };
PARAM st05 = { 0, -4, 0, 0 };
PARAM st06 = { 0, -3, 0, 0 };
PARAM st07 = { 0, -2, 0, 0 };
PARAM st08 = { 0, -1, 0, 0 };
PARAM st09 = { 0,  1, 0, 0 };
PARAM st10 = { 0,  2, 0, 0 };
PARAM st11 = { 0,  3, 0, 0 };
PARAM st12 = { 0,  4, 0, 0 };
PARAM st13 = { 0,  5, 0, 0 };
PARAM st14 = { 0,  6, 0, 0 };
PARAM st15 = { 0,  7, 0, 0 };
PARAM st16 = { 0,  8, 0, 0 };

TEMP r00, r01, r02, r03, r04, r05, r06, r07, r08, base, color;

MUL r00, fragment.position, program.env[1];
MUL r00, r00, program.env[0];

# bottom side

MAD r01, size, st01, r00;
MAD r02, size, st02, r00;
MAD r03, size, st03, r00;
MAD r04, size, st04, r00;
MAD r05, size, st05, r00;
MAD r06, size, st06, r00;
MAD r07, size, st07, r00;
MAD r08, size, st08, r00;

TEX r01, r01, texture[1], 2D;
TEX r02, r02, texture[1], 2D;
TEX r03, r03, texture[1], 2D;
TEX r04, r04, texture[1], 2D;
TEX r05, r05, texture[1], 2D;
TEX r06, r06, texture[1], 2D;
TEX r07, r07, texture[1], 2D;
TEX r08, r08, texture[1], 2D;

MUL color.xyz, r01, mu01;
MAD color.xyz, r02, mu02, color;
MAD color.xyz, r03, mu03, color;
MAD color.xyz, r04, mu04, color;
MAD color.xyz, r05, mu05, color;
MAD color.xyz, r06, mu06, color;
MAD color.xyz, r07, mu07, color;
MAD color.xyz, r08, mu08, color;

# top side

MAD r01, size, st09, r00;
MAD r02, size, st10, r00;
MAD r03, size, st11, r00;
MAD r04, size, st12, r00;
MAD r05, size, st13, r00;
MAD r06, size, st14, r00;
MAD r07, size, st15, r00;
MAD r08, size, st16, r00;
MIN r01, r01, program.env[0];
MIN r02, r02, program.env[0];
MIN r03, r03, program.env[0];
MIN r04, r04, program.env[0];
MIN r05, r05, program.env[0];
MIN r06, r06, program.env[0];
MIN r07, r07, program.env[0];
MIN r08, r08, program.env[0];

TEX base, r00, texture[0], 2D;
TEX r00, r00, texture[1], 2D;
TEX r01, r01, texture[1], 2D;
TEX r02, r02, texture[1], 2D;
TEX r03, r03, texture[1], 2D;
TEX r04, r04, texture[1], 2D;
TEX r05, r05, texture[1], 2D;
TEX r06, r06, texture[1], 2D;
TEX r07, r07, texture[1], 2D;
TEX r08, r08, texture[1], 2D;

MAD color.xyz, r00, mu09, color;
MAD color.xyz, r01, mu08, color;
MAD color.xyz, r02, mu07, color;
MAD color.xyz, r03, mu06, color;
MAD color.xyz, r04, mu05, color;
MAD color.xyz, r05, mu04, color;
MAD color.xyz, r06, mu03, color;
MAD color.xyz, r07, mu02, color;
MAD color.xyz, r08, mu01, color;

MAD result.color.xyz, color, 0.5, base;

END
