varying vec3 LightDir;
varying vec3 EyeDir;
varying vec4 color;

attribute vec3 spcVertexTangent;

void main()
{

 EyeDir = vec3(gl_ModelViewMatrix * gl_Vertex);
 vec3 LightPosition =vec3(gl_ModelViewMatrix* gl_LightSource[0].position);
 gl_Position=ftransform();
 gl_TexCoord[0] = gl_TextureMatrix[0]*gl_MultiTexCoord0;
 gl_TexCoord[1] = gl_TextureMatrix[1]*gl_MultiTexCoord0;
 color = gl_Color;


 vec3 n = normalize(gl_NormalMatrix * gl_Normal);
 //n*=-1;
 
 
 vec3 lol = spcVertexTangent;
 vec3 t = normalize(gl_NormalMatrix * lol);
 vec3 b = cross(t,n);

 //LightDir = vec3(gl_ModelViewMatrix * vec4(LightPosition,0.0));
 vec3 v;
 v.x = dot(LightPosition,t);
 v.y = dot(LightPosition,b);
 v.z = dot(LightPosition,n);

LightDir = normalize(v);

v.x = dot(EyeDir,t);
v.y = dot(EyeDir,b);
v.z = dot(EyeDir,n);

EyeDir = normalize(v);

}
