VisionOSSortingGroup is not working as expected

I’m attempting to render a cube situated behind a car using VisionOSSortingGroup. It functions correctly with the Depth Pass set to Post Pass, but results in incorrect rendering of my car model. Conversely, when selecting other depth pass options, the car is rendered accurately, yet the cubes become invisible. Any recommendations on achieving a desired result?

Depth Pass set to Post Pass (you can see one cube here):

Depth Pass set to Pre Pass:

Depth Pass set to Unseparated

Yeah, I don’t think there’s really a way to get the effect you want using VisionOSSortingGroup (or the underlying component that it uses in RealityKit, ModelSortGroupComponent). The problem is that there’s no way to have a material ignore depth checks (that is, Depth Test is always LEqual) or avoid writing to the depth buffer. You can only change the time at which the depth buffer is written to (for the elements of a given sorting group) using the Depth Pass setting:

  • Post Pass: the depth is written after all members of the group are drawn. The order = -1 cube is visible (because it’s rendered last), but the car has invalid depth compositing (because the entire car is drawn before the depth buffer is populated).
  • Pre Pass: the depth is written before any members of the group are drawn. The car depth composites correctly (because the depth buffer is populated), but the order = -1 cube isn’t visible (because it fails the depth check).
  • Unseparated: the depth is written at the same time each element of the group is drawn. Again, the car composites correctly, but the order = -1 cube fails the depth check.

If it were possible to have a material ignore the depth buffer (i.e., Depth Test = Always), then you could use that setting on the cube material and have it render in front of the car (regardless of the Depth Pass setting). I would suggest providing feedback to Apple via their Feedback Assistant indicating that this is a feature you would like to see on their material types (UnlitMaterial, PhysicallyBasedMaterial, ShaderGraphMaterial).

1 Like