varying vec3 lightPos;
varying vec3 eyePos;
varying vec3 lightColor;
varying vec4 projPos;
varying vec3 normal;

varying float invRadius;
varying float extraParam;

void main()
{
  // get texcoords from vertex
  gl_TexCoord[0].st = gl_Vertex.st * 0.5 + 0.5;

  // extract world position
  invRadius = 1.0;//1.0 / gl_MultiTexCoord1.w;
  
  // model to world
  gl_Position = vec4( gl_MultiTexCoord1.xyz + (/*gl_MultiTexCoord1.www**/gl_Vertex.xyz) , 1.0 );
  
  gl_TexCoord[0].st = gl_Position.xz;

  eyePos = ( gl_ModelViewMatrix * gl_Position ).xyz;
  
  // view projection
  gl_Position = gl_ModelViewProjectionMatrix * gl_Position;
  projPos = gl_Position;
  
  // position in eyespace
  lightPos = ( gl_ModelViewMatrix * vec4( gl_MultiTexCoord1.xyz, 1.0 ) ).xyz;

  normal = eyePos - lightPos;
    
  // color from params
  lightColor = gl_MultiTexCoord2.xyz;
  extraParam = gl_MultiTexCoord2.w;
}
