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?