varying vec3 position;
varying vec4 diffuse,ambientGlobal,ambient,normal;
varying vec3 lightDir,halfVector;
varying float dist;

void main( void ) {
  vec4 ecPos;
   vec3 aux;

	//ljus
	ecPos = gl_ModelViewMatrix * gl_Vertex;
	aux = vec3(gl_LightSource[0].position-ecPos);
	lightDir = normalize(aux);
	dist = length(aux);
	halfVector = normalize(gl_LightSource[0].halfVector.xyz);

	diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
	ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
	ambientGlobal = gl_LightModel.ambient * gl_FrontMaterial.ambient;




	vec4 viewPos = gl_ModelViewMatrix * gl_Vertex;
	normal.a = -viewPos.z/500.0;
	//normal.a = -length(viewPos)/500.0;


	gl_Position = ftransform();
	normal.xyz = normalize(( gl_ModelViewMatrix * vec4( gl_Normal.xyz, 0.0 ) ).xyz);

}
