Is it possible to force meshes to be drawn fully one after another (overlapping instead of clipping?)

Or, in essence, disable depth testing. I’ve tried adding:

engine.setDepthFunction(engine._gl.ALWAYS);

But objects still clip through each other.

You can use the renderingGroupId property of the mesh to apply the rendering order you want between meshes.

Note that for disabling depth testing you should either use material.depthFunction = Constants.ALWAYS or engine.setDepthFunction(Constants.ALWAYS), but you should avoid to directly access the gl context.

In order to use rendering group ID (which would be the best possible outcome, because then game objects that are composed of multiple meshes wouldn’t be wonky) to assign each game object to its own layer, I’d need to be able to use dozens of rendering groups. Is that possible? I thought you could only use a handful.

You can have 4 different rendering group id by default but it can be raised.

However, there must be a better way of achieving what you want to do: do you care setting a repro PG so that we can dig further?

Raising the number of rendering groups sounds like exactly what I’d want to do though, how do you do that?

I’ll set up a playground when I get a chance, it’ll be a bunch of overlapping spheres and boxes and such.

You can set BABYLON.RenderingManager.MAX_RENDERINGGROUPS to the number of groups you want.

Note that you will incur some performance and/or memory penalty because a RenderingGroup instance is created for each render group. However, you will need to profile your app to see if it’s a bottleneck for you or not.

I don’t understand what you want to achieve with multiple rendering groups for this use case?

It seems to me that you want to render your meshes in a precise order: create the meshes in the order you want, the system will render them in this order (except if there are some transparent meshes in the mix, that will be rendered after the opaque meshes and sorted from back to front).

Because I’m drawing a fairly sparse scene, I was able to get away with having a huge number of rendering groups! Here’s the result I was after, working perfectly:
overlay
Note that the (glowing red) cannons clip through the parent ships (to give them that built-in look) but the two spaceships don’t clip into each other. That’s the exact effect I was after.