Make depth testing work for alpha fragments, by rendering opaque fragments to a framebuffer first, using the same renderbuffer for depth+stencil as the other two framebuffers both use.  Also do more passes on the explicit stencil values, in an attempt to make the green pixels work a little better (because the "all other values" total_layers uniform is too low most of the time).