Issue with custom shapes rendering

That’s the same problem than here: Have only certain meshes visibile through transparency?

Why not using a material without alpha for the pieces that don’t need transparency?

https://playground.babylonjs.com/#NXRT8H#1

Alternatively, instead of enduring the penalty for needDepthPrePass = true you can simply set mat1.forceDepthWrite = true:

https://playground.babylonjs.com/#NXRT8H#2