single pass rendering of transparent objects

I have looked at various open source engines to get ideas for handling rendering of transparent and opaque objects. Most of them tend to sort drawing operations based on whether they’re transparent or not, and draw the transparent later with the zbuffer disabled. However, for my engine, I’m not readily willing to build in a way of requesting whether the drawing operation could be transparent. So I decided I would use alpha tests in jogl to cull first transparent pixels, draw all objects, disable zbuffer, cull opaque pixels only, draw all objects again. I’m hesitant to do this because it requires two passes and could get expensive.

So finally, at last, my question is, would it be possible to write a fragment shader that calculates or receives the incoming fragment color, writes the color properly, but only writes the depth value if the fragment is fully opaque. I haven’t looked really into whether or not fragment shaders are allowed to modify the depth of incoming fragments, but if I could do this, wouldn’t it properly draw transparent scenes with only one pass?

So I looked at the GLSL spec and found that if the depth buffer is enabled for writing, that either the calculated depth value for the frag coord is used, or I can write my own using gl_FragDepth. If I don’t write a value to gl_FragDepth, a value is taken from the coordinate. The coordinate’s depth is read only and I have no way of accessing (to my knowledge) the depth buffer. Is there anyway to make it so that no depth value is written at all to the depth buffer with a fragment shader?