varying vec4 TexCoord;
varying float fogFactor; 


uniform vec4 Tangent;
uniform vec4 Normal;
uniform vec4 BiNormal;

//uniform vec4 Eye;
//varying vec3 EyeDir;

varying vec3 lightDir;
varying vec3 halfVector;


void main(void)
{
  gl_Position = ftransform();//gl_ModelViewProjectionMatrix* gl_Vertex;
  TexCoord = gl_Color;
  

  /*
  vec3 m_Tangent = vec3(gl_ModelViewMatrix * Tangent);
  vec3 m_Normal = vec3(gl_ModelViewMatrix * Normal);
  vec3 m_BiNormal = vec3(gl_ModelViewMatrix * BiNormal);

  // Also, transform the vertex into view-space.
  vec3 m_Vector = vec3(gl_ModelViewMatrix * gl_Vertex);

  // Calculate the direction of the Eye
  // Position from the vertex;
  vec3  EyeDir   = Eye.xyz  - m_Vector;
        
  // Put the Eye Direction into tangent space
  //EyeDir.x = dot(m_Tangent.xyz , dirEye);
  //EyeDir.y = dot(m_BiNormal.xyz , dirEye);
  //EyeDir.z = dot(m_Normal.xyz , dirEye);
  */
  
  // BumpMapping ======================================================
  /*
  vec3 n = normalize(gl_NormalMatrix * gl_Normal);
  vec3 t = normalize(gl_NormalMatrix * TexCoord0);
  vec3 b = cross(n, t) * TexCoord0;
    
  mat3 tbnMatrix = mat3(t.x, b.x, n.x,
                        t.y, b.y, n.y,
                        t.z, b.z, n.z);
    
  lightDir = gl_LightSource[0].position.xyz;
  lightDir = tbnMatrix * lightDir;
    
  halfVector = gl_LightSource[0].halfVector.xyz;
  halfVector = tbnMatrix * halfVector;*/
  
  // FOG ================================================================
  vec3 m_Vector = vec3(gl_ModelViewMatrix * gl_Vertex);
  const float LOG2 = 1.442695;
  gl_FogFragCoord = length(m_Vector);
  fogFactor = exp2( -gl_Fog.density * 
					   gl_Fog.density * 
					   gl_FogFragCoord * 
					   gl_FogFragCoord * 
					   LOG2 );
  fogFactor = clamp(fogFactor, 0.0, 1.0);

}

