depth peeling - back to front

I’ve recently implemented depth peeling translucency based on Cass Everitt’s white paper. Now I’d like to modify it by rendering the layers in back to front order rather than the other way around. It seems like there would be advantages for my application. The problem is that I can’t figure out how to terminate rendering the layers. It seems like an efficient way to do it would be to stop when all fragments pass the fragment depth test (none are rejected). Or, a little less efficient but only doing one extra layer, when all fragments are rejected by the depth texture alpha test. Just selecting a number of layers to render doesn’t work near a nicely as for the front to back depth peeling because if there a too few the fragments nearest to the camera are never rendered, and too many results in a lot of wasted extra passes through the geometric objects. I haven’t been able to figure out how to implement any of these ideas in OpenGL or to come up with any solutions that I can implement. As an added challenge I’m trying to stay away from vendor specific extensions. Anyone have and ideas?

you could perhaps use an occlusion query ?

Thanks, I’ll look into the occlusion query!

On a side note, I just realized that stopping when all fragments pass the fragment depth test won’t work because it requires the incoming fragments to be depth ordered.