varying vec3  eyeDir;
varying vec3  normal;
varying vec3  up;
varying float fog;

void main()
{
  float z;
  vec4 eyePos = gl_ModelViewMatrix * gl_Vertex;
  z = -eyePos.z / eyePos.w;
  
  // fog
  fog = ( 1000.0 - z ) / ( 1000.0 );
  fog = max( fog, 0.0 );

  // eye position
  eyeDir = eyePos.xyz;
  eyeDir = normalize( eyeDir );
 
  // normal
  normal = normalize(gl_NormalMatrix * gl_Normal);
  up     = normalize( gl_NormalMatrix * vec3( 0.0, 1.0, 0.0 ) );

  // update position
  gl_Position = ftransform();

  // texture coords
  gl_TexCoord[0] = gl_MultiTexCoord0;
}
