OpenGL Depth Buffer with transparency

Dear forum,
I’ve already implemented transparency into my program.
If there is transparency in an object, i disable backface culling and in The fragment
schader, i discard every pixel where the alpha-value is less than 0.5 .
That works fine, but if i have half transparent objects, i cannot just discard it.
But if i render that pixel, its also writing into the depth buffer and any objects behind this one are
not being rendered.
How can I handle this problem ?

https://www.opengl.org/wiki/Transparency_Sorting#Draw_opaque_objects_first

as far as i know, you have to sort all transparent faces after their distance to the scene’s camera (from the furthest to the closest), then you have to draw first all totally opaque faces (alpha ~ 1.0), then you draw all transparent faces (alpha < 1.0)

http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-10-transparency/

Transparency requires that fragments are rendered in a specific order, either from back to front or front to back.

Specific approaches include:

  • render the polygons in a particular order (requires a topological sort, and may require splitting polygons to avoid circular dependencies)
  • depth peeling (multiple passes using render-to-texture and two depth buffers)
  • storing a linked list of fragments for each pixel and sorting the lists.