!!ARBfp1.0
OPTION ARB_precision_hint_fastest;


# Purpose:


# Input Parameters:
# Tex 0: Frame buffer texture
# TexCoord 0: Texel in the frame buffer
# TexCoord 1: Texel in the distortion lookup buffer.
# Env 0: Intensity of the effect.
#	  x: Intensity.
# Env 1: Lookup offset.
#	  x: X offset.
#	  y: Y offset.
#	  z: 0.0
#	  w: 0.0
# Env 2: Distortion size.
#	  x: size.
#	  y: size / 2.


TEMP framebuffer, distortion, finalcolor;

TEMP lookup;

MUL lookup, fragment.texcoord[1], 0.2;
ADD lookup, lookup, program.env[1];

# Make a lookup in the distortion buffer.
TEX distortion, lookup, texture[1], 2D;

TEMP distortedlookup;
MAD distortedlookup, distortion, program.env[2].x, -program.env[2].y;
MOV distortedlookup.zw, {0.0, 0.0, 0.0, 1.0};

ADD lookup, fragment.texcoord[0], distortedlookup;
TEX framebuffer, lookup, texture[0], 2D;

MOV finalcolor, framebuffer;

MOV result.color.rgb, finalcolor;
MOV result.color.a, program.env[0].x;

END