uniform sampler2D TextureParticle;
uniform sampler2D AlphaParticle;
varying vec4 EyeSpacePosition;
varying vec2 uv;
varying vec2 uv2;

void main(void)
   {
   vec2 p = uv;
   
   vec4 LocalEyeSpacePosition = vec4
         (
         EyeSpacePosition.x-uv.x/2.0,
         EyeSpacePosition.y-uv.y/2.0,
         EyeSpacePosition.z,
         EyeSpacePosition.w
         );

   vec4  c = texture2D(TextureParticle, uv2)  ; 
   c.w = texture2D(  AlphaParticle, uv2).x;


      // calcular la h de la esfera que encajaria en el quad en el pixel actual
      vec4 value = vec4(0.0,0.0,c.w*0.45,0.0);// hack : este valor corrector no se exactamente que hace
      
      // proyectar el punto
      vec4 newpoint = (LocalEyeSpacePosition-value) * gl_ProjectionMatrix;
      gl_FragDepth = newpoint.z/newpoint.w;// + value.z;
      gl_FragColor = c;
}