Post processing with changing positions

Hi, I’m trying to understand postprocessing effects, particularly selectively applying effects to select scenes and layers. I think I’m getting the hang of painting layers on top of each other, but I’m having trouble with objects that have a changing paint order.

I’m wondering is it possible to modify the following example so the effectComposer knows which part of the meshes are in front / behind each other? https://threejs.org/examples/?q=mask#webgl_postprocessing_masking

The current example will always paint the torus on top - can you make the effectComposer aware of the mesh depth? So if the torus moves behind the cube then the cube is painted on top? Or even if the cube is inside the torus, could you paint part of the torus on top and the other behind?

From what I understand I could create a texture material using a RenderTarget? But what if wanted to do something like blur the object? I believe the edges would stay crisp with a material.