I’m having issues with transparent objects rendering before opaque objects, and have tried to use PolySpatialSortingGroup to fix the issue. But it doesn’t seem to work for me; there is no change to the order of the objects being rendered.
I can’t seem to find it being used in the template or sample projects. Is there an example of how it should be set up and working?
In its current form, PolySpatialSortingGroup is basically a way to apply the RealityKit component ModelSortGroupComponent to specific game objects, so its effects won’t show up in Unity play mode.
Couple things to note other than that - the renderers added to the PolySpatialSortingGroup list should not be sprite renderers or canvas - those have their own sorting system. PolySpatialSortingGroup is intended for use with mesh renderers only.
For the DepthPass property, only post-pass works right now in RealityKit - I’ll follow up with the RealityKit team and see if that’s expected.
As for adding it to the templates or samples, I remember there was some plans to add the sorting group component to templates to order transparent objects and opaque objects - I’ll see where that ended up and hopefully we can add an example of its usage to the templates project.
I was unable to get the sorting to work correctly using the PolySpatialSortingGroup setup. In our use case we have a transparent water mesh with a terrain both above and below. It is impossible to setup the PolySpatialSortingGroup to work with this scenario, as the water will either be rendered as solid or the terrain will be rendered as transparent, depending on the setting of the DepthPass property.
The only way to fix this sorting is to modify the geometry. Either by splitting the terrain into an above and below mesh, or changing the bounds of the water mesh. I’ve opted for the latter approach. I’m adding a single dummy vertex to the water mesh, which extends the bounds upwards. It seems like the mesh.bounds property is not passed to RealityKit, otherwise it would have been simpler to modify that…
(The PolySpatialSortingGroup works well for our custom UI, which consists of flat meshes with no intersections)
@vcheung-unity Following up on this, is post-pass still the only currently working one, and are there plans to add to templates/samples to show PolySpatialSortingGroup?
As for adding it to the template project, the work for it is done for the most part, just need approval from a designer who is currently out for the week. I am hoping it will be available soon, maybe by next release, but the holidays may throw a wrench in those plans.