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

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

END 


# ============================================================================== 
# largely based on bloom.vfp by Nathan Ostgard - nostgard+doom3 at gmail.com 
!!ARBfp1.0 OPTION ARB_precision_hint_nicest; 

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

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

# fragment offsets for blur samples 
PARAM offset01 = {  0.0, -1.0, 0, 0 }; 
PARAM offset02 = { -1.0,  0.0, 0, 0 }; 
PARAM offset03 = {  1.0,  0.0, 0, 0 }; 
PARAM offset04 = {  0.0,  1.0, 0, 0 }; 
PARAM offset05 = { -2.0, -2.0, 0, 0 }; 
PARAM offset06 = {  2.0, -2.0, 0, 0 }; 
PARAM offset07 = { -2.0,  2.0, 0, 0 }; 
PARAM offset08 = {  2.0,  2.0, 0, 0 }; 

# (1 / numOffsets) * 0.5 
PARAM   scale = 0.0625; 

MOV   r0, fragment.texcoord[0]; 

# calculate our offset texture coordinates 
MAD   r1, size, offset01, r0; 
MAD   r2, size, offset02, r0; 
MAD   r3, size, offset03, r0; 
MAD   r4, size, offset04, r0; 
MAD   r5, size, offset05, r0; 
MAD   r6, size, offset06, r0; 
MAD   r7, size, offset07, r0; 
MAD   r8, size, offset08, r0; 

# sample the current render for each coordinate 
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; 
TEX   r8, r8, texture[0], 2D; 

# add up the blurred samples and get the average 
ADD   r1, r1, r2; 
ADD   r1, r1, r3; 
ADD   r1, r1, r4; 
ADD   r1, r1, r5; 
ADD   r1, r1, r6; 
ADD   r1, r1, r7; 
ADD   r1, r1, r8; 

MAD   result.color.xyz, r1, scale, r0; 
MAD   result.color.xyz, r1, 0.125, r0; 

END
