Overlaying SwiftUI content with transparency in front of RealityView

Following up on my previous question here: https://developer.apple.com/forums/thread/774262

Having solved the clipping problem, I am now trying to overlay some content in front of the RealityView. However, it looks like any content with transparency does not render in front of the RealityView, while opaque views seem to work; placing content with transparency like glassBackgroundEffect() behind the RealityView in a ZStack causes the entire window to flicker.

Additionally, my SwiftUI attachment placed in front of the stereoscopic image plane are invisible if the user look at it straight at 90 degrees. However, if the user look at it from increasing angles from the sides, the attachment gradually turns visible again.

Are these behaviors expected? What is a recommended approach to overlay content in front of a RealityView? Thanks!

Hi @NSCruiser

The flickering sounds like z-fighting. I was able to recreate the flicker and fixed it by applying a small z offset to the plane. Try adding this just after you create the box in StereoImageCreator.

box.position.z = 0.001

I didn't test this, but try a similar fix for the attachment entity.

attachment.position.z = 0.002

Please accept this answer if it fixes the issue. Otherwise please followup. If you do followup, please provide a link to a project that contains a focused reproduction of the issue (or post the relevant code here) so I can better help you.

Overlaying SwiftUI content with transparency in front of RealityView
 
 
Q