How to make depth test work between translucent materials?

I have two translucent but high-opacity primitives that clip into each other. In their materials, both have “Output Depth and Velocity” enabled and “Disable Depth Test” disabled. Unfortunately one always appears on top of another; they don’t clip properly. Is there any way to make the depth test work properly, so that the one drawn first can mask the one drawn second when it is in front?

Basically, I want them to behave like the back one is an opaque/masked material, but I can’t do that directly because it samples from the custom stencil buffer.