varying vec2 TexCoord;
varying vec4 pos;

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

   if (d_squared<=1.0)
      {   
      float h = sqrt(1.0-d_squared);
      gl_FragColor = vec4(h);
      gl_FragDepth = (pos.z-0.5*h)/pos.w;
}
   else
      {
      discard;
      //gl_FragColor = vec4(1.0,0.0,0.0,0.0);
      }
   
   
}