<arbfp>
  <description>parallax fragment</description>
   
  <variablemap variable="light 0 diffuse" destination="register 1"/>
      
<program>
    <![CDATA[
!!ARBfp1.0

PARAM light0color = program.local[1];

ATTRIB iTex0		= fragment.texcoord[0];
ATTRIB iLightDir		= fragment.texcoord[1];
ATTRIB iEyeVec		= fragment.texcoord[2];
ATTRIB iCol0		= fragment.color;
# Outputs
OUTPUT oCol 		= result.color;

TEMP eyevects;
TEMP rgb, normal, height, temp, bump, total;
TEMP light0tsvec;
TEMP newtexcoord;


TEMP normalizedEyeVector;
TEMP heightVal;

# normalize tangent space eye vector
DP3 temp, iEyeVec, iEyeVec;
RSQ temp, temp.x;
MUL normalizedEyeVector, iEyeVec, temp;

# calculate offset and new texture coordinate
TEX height, iTex0, texture[2], 2D;
MAD height, height, 0.04, -0.02;  # scale and bias
MAD newtexcoord, height, normalizedEyeVector, iTex0;

# get texture data
TEX rgb, newtexcoord, texture[1], 2D;
TEX normal, newtexcoord, texture[0], 2D;

# remove scale and bias from the normal map
MAD normal, normal, 2.0, -1.0;

# normalize the normal map
#DP3 temp, normal, normal;
#RSQ temp, temp.r;
#MUL normal, normal, temp;

# normalize the light0 vector
DP3 temp, iLightDir, iLightDir;
RSQ temp, temp.x;
MUL light0tsvec, iLightDir, temp;

# normal dot lightdir
DP3 bump, normal, light0tsvec;

# add light0 color
MUL_SAT total, bump, light0color;

# multiply by regular texture map color
MUL_SAT result.color, rgb, total;


END
]]>
  </program>
</arbfp>

