!!ARBvp1.0
# Original Input...
ATTRIB OriginalPos   = vertex.position;		# Input vertex position.
ATTRIB OriginalColor	= vertex.color;			# Input vertex color.
ATTRIB OriginalNormal= vertex.normal;        # Input vertex normal.
ATTRIB OriginalTex1	= vertex.texcoord[1];	# Input texture coordinate 1.
ATTRIB OriginalTex0	= vertex.texcoord[0];	# Input texture coordinate 1.

# Vertex Output...
OUTPUT OutPos			= result.position;		# Output position.
OUTPUT OutColor		= result.color;			# Ouput color.
OUTPUT OutTex0			= result.texcoord[0];	# Output texture coordinate 0.
OUTPUT OutTex1			= result.texcoord[1];	# Output texture coordinate 1.

# Constant variables...
PARAM ModelViewProj[4]  = { state.matrix.mvp }; # Modelview Projection Matrix.
PARAM IMV[4]  = { state.matrix.modelview.invtrans };
PARAM LightPosition     = program.env[0];       # Translation value sent in from the application.
PARAM ModelPos     = program.env[1];       # Translation value sent in from the application.

# Temporary variables...
TEMP lightVector;
TEMP lightVectorNormal;                      # Just a temporary variable.
TEMP OutNorm;
#TEMP ModelPos;



#**************************************************
# BODY ViewPos
#**************************************************


# Here each axis is transformed into clip space.
DP4 OutPos.x, ModelViewProj[0], OriginalPos;
DP4 OutPos.y, ModelViewProj[1], OriginalPos;
DP4 OutPos.z, ModelViewProj[2], OriginalPos;
DP4 OutPos.w, ModelViewProj[3], OriginalPos;



DP3  OutNorm.x, IMV[0], OriginalNormal;                  
DP3  OutNorm.y, IMV[1], OriginalNormal;                
DP3  OutNorm.z, IMV[2], OriginalNormal;                  
# and normalise                                
DP3  OutNorm.w, OutNorm, OutNorm;              
RSQ  OutNorm.w, OutNorm.w;                    
MUL  OutNorm, OutNorm, OutNorm.w;

# Send the original color to set the output color.
MOV OutColor, OriginalColor;


# Calculate the light vector.

SUB lightVector, LightPosition, ModelPos;
DP3 lightVectorNormal.w, lightVector, lightVector;
RSQ lightVectorNormal.w, lightVectorNormal.w;
MUL lightVectorNormal.xyz, lightVectorNormal.w, lightVector;



DP3 OutTex1.x, lightVectorNormal, OutNorm;
MOV OutTex0, OriginalTex0;

END


