Transparency for groups of meshes

Is there a way to make a group of meshes transparent together, such that no parts of that group are visible through the other parts? Kind of like the effect that needDepthPrePass has for a single mesh.

Here’s a playground to illustrate:

When looking through the spheres at the pyramids, the green box is visible through the sphere, while the red box is only visible outside of the sphere. This works for the red box as it’s merged into a single mesh with the sphere and needDepthPrePass is set to true. I wonder if there’s a way to get a similar effect for the green box, while keeping the meshes and materials distinct.

something like disableColorWrite ?
check the pyramids : https://playground.babylonjs.com/#3KXSUZ#1

1 Like