Help understanding Group.renderOrder and Mesh.renderOrder

Is there documentation on how renderOrder works with Groups and Meshes? Or does anyone have an intuitive way of thinking about it? I’ve looked through the source and it’s not super clear to me. It seems that only the immediate parent group of any given Mesh actually impacts the render order of a mesh and group renderOrder is only compared to other groups. Here are a couple scenarios that seemed a bit confusing to me:

Group A (RO 3)
    └ Mesh A (RO 0)
Group B (default RO 0)
    └ Mesh B (RO 1)

In the above case Mesh B will render before Mesh A because of the group renderOrder but in the following scenario:

Group A1 (RO 2)
    └ Group A2 (default RO 0)
        └ Mesh A (RO 0)
Group B (default RO 0)
    └ Mesh B (RO 1)

Mesh A renders before Mesh B because a new group has been inserted that overrides the existing group render order. And in the following case:

Scene
    └ Group (RO 2)
        └ Mesh A (RO 1)
    └ Mesh B (RO 3)

Mesh B will draw first despite having the largest renderOrder because the default group order is 0.

I guess I’m wondering how other people have been using Group.renderOrder and whether they have any suggestions regarding how to think about the group render order values compared to the Meshes so it’s less confusing. Otherwise maybe there’s a way to rework the behavior of renderOrder so it’s a bit more intuitive?

Looking back at some previous PRs it looks like it was intended to support something similar to Unity’s SortingGroup, which I don’t feel this quite achieves specifically with the behavior in the first example I listed above. One solution might be to set the Group renderOrder to null by default to imply that a child group should not override the parent group’s renderOrder? It’s not perfect but it might afford some more flexibility.

Thanks!

1 Like

Indeed, the Group.renderOrder is not really usable in real-world scenarios IMO (I would be happy to discuss with someone that used this feature to his own benefit to see how he used it). And no, it’s not like Unity’s SortingGroup.

You can read some comments I made about it here:

As I had hijacked the thread :woozy_face:, you will have to click on “Show comment” to see it