I'm trying to make a group of foreground objects transparent as a single entity, where they occlude each other like solid objects and then have transparency applied after, instead of each individual one having its own transparency.
There is an option in the material settings called Show Backface, but that only works for single objects. Is there a way to apply this effect for a group of objects? Merging shouldn't be an option as the foreground may also contain rigged characters and such. The objects in the screenshots below are only to demonstrate what I mean.
I also thought about compositing the foreground and background together as separate layers, but then I run into a problem of the background not containing shadows of the foreground (and vice versa), or if I render foreground + background as one layer and only background as second layer, then the shadows occluded by the foreground will start fading out too. Another thing I thought about was duplicating the whole foreground and giving everything a fully transparent material to render the background with shadows, but I'd rather avoid duplicating anything.
Is something like this possible? Compositor solutions are also welcome.