varying vec3 eyeVec;

uniform vec3 view_position;

varying vec3 tangent;
varying vec3 biNormal;
varying vec3 normal;

uniform vec3 lightPos;
varying vec3 lightVec;

uniform vec4 invCamX;
uniform vec4 invCamY;
uniform vec4 invCamZ;
uniform vec4 invCamW;

varying float col;

attribute vec3 spcVertexTangent;
void main()
{
 mat4 invCam;
 invCam[0]=vec4(invCamX);
 invCam[1]=vec4(invCamY);
 invCam[2]=vec4(invCamZ);
 invCam[3]=vec4(invCamW);
 gl_TexCoord[0]=gl_MultiTexCoord0;
 gl_TexCoord[1]=gl_TextureMatrix[1]*gl_MultiTexCoord0;
 gl_Position=ftransform();
vec4 eyeVecz = vec4(gl_ModelViewMatrix*gl_Vertex);
 
 normal = normalize(gl_Normal);
 tangent = (vec4(spcVertexTangent,0.0)).xyz;
 biNormal = normalize(cross(normal,tangent));
 
 vec3 tempLightVec = vec3(lightPos.x,lightPos.y,lightPos.z);
 tempLightVec -= (gl_Vertex).xyz;
 lightVec.x = dot( tempLightVec, tangent ); 
 lightVec.y = dot( tempLightVec, biNormal ); 
 lightVec.z = dot( tempLightVec, normal ); 
 
 vec3 tempEye = (eyeVecz).xyz;
 eyeVec.x = dot( tempEye, tangent ); 
 eyeVec.y = dot( tempEye, biNormal ); 
 eyeVec.z = dot( tempEye, normal ); 
 
 col = clamp(gl_Vertex.y/500.0,0.0,1.0);
 
}