Using Discard in the Fragment Shader to make Objects Disappear

Hi dears, 

So a question from John triggered me and I had to create this little algorithm.

The spheres disappear starting from one extremity, according to a threshold.

The algorithm for that is pretty trivial, just calculate the distance between one extremity of the sphere ( vec3(0,0,1) ) and all the vertices of the sphere. If the distance is less than the treshold discard those pixels. 

The cool thing is that it also has the light on the back face thanks to the gl_FrontFace built-in variable, which allows us to flip the normals for the faces inside.

I uploaded a video of the patch on FB:

Take a look at the shader and enjoy! 

Thank you a lot for your support!