varying vec2 TexCoord;
varying vec4 pos;
uniform bool UseColor;
varying vec4 EyeSpacePosition2;
varying vec4 EyeSpacePosition;

void main( void )
   {
   vec2 p = TexCoord;
   p = p * 2;
   float d_squared = p.x*p.x+p.y*p.y;

   if (d_squared<=1.0)
      {   
      float h = sqrt(1.0-d_squared);
      vec4 value = vec4(0,0,h*0.45,0);
      vec4 newpoint = gl_ProjectionMatrix*(EyeSpacePosition+value);
      gl_FragColor = normalize(EyeSpacePosition2 - EyeSpacePosition);
      gl_FragColor.w = EyeSpacePosition.z; 
      gl_FragDepth = (pos.z-0.5*h)/pos.w;
      }
   else
      {
      discard;
      //gl_FragColor = vec4(1.0,0.0,0.0,0.0);
      }
   
   
}