INSTANCEDMESH_SORT_TRANSPARENT is only local to the mesh: it correctly sorts the instances of a given mesh (the sorting is done when the source mesh is drawn), but it cannot sort instances between several meshes.
So, if mesh A has 10 instances and mesh B 5 instances, the 10 instances of A will be correctly sorted, as will the 5 instances of B. But if some instances of A are further apart than some instances of B, and others are closer, then you’ll get rendering artifacts.
In the case of the PG, we can set the alphaIndex to 0 for the sun so that it is rendered before the spheres:
Currently, I’m creating a bigger scene where I will have multiple meshes, each with numerous instances. What would be the best approach to sort the rendering order dynamically where all of them needs to support transparency?
If you really need all instances from all meshes to be correctly sorted, then you won’t be able to use instances at all… You will need to use regular meshes.
I have a similar issue but with two normal meshes. I’m not using instances. One mesh is a house’s wall and the other mesh is 80 individual studs of the wall’s interior. Their geometries don’t intersect or overlap, the studs are fully inside the bounds of the wall. But when their materials are set at 0.7 transparency there are certain camera positions where it insists on rendering the studs on top of the walls, despite the walls always being closer to the camera.
I’m using MATERIAL_ALPHABLEND but I’m seeing that perhaps this is just a limitation. If there are only 4 groups, and the center point of the entire mesh is what is used to layer them, then I guess this is just how it it. Might try out PBR.