Attachment layer hidden behind visionOS app window in immersive space

Hello,

To me, it does not seem to be entirely clear why, when I'm trying to display my attachment, no matter the positioning, it will always be hidden/covered by my visionOS app window. I'm trying to achieve displaying the attachment one layer above/in front of the window. When my head isn't directed towards the window I can see the attachment but else it's covered by it.

I appreciate any help!

ContentView.swift

import SwiftUI
import RealityKit

struct ContentView: View {
    
    @Environment(\.openImmersiveSpace) private var openImmersiveSpace
    
    public var body: some View {
        VStack {
            Text("Hello World")
                .font(.largeTitle)
            Button("Start") {
                Task {
                    await openImmersiveSpace(id: "AppSpace")
                }
            }
        }
    }
}

ImmersiveView.swift

import SwiftUI
import RealityKit

struct ImmersiveView: View {
    var loader: EnvironmentLoader
    
    public var body: some View {
        
        RealityView { content, attachments in
            content.add(try! await loader.getEntity())
           
            let headEntity = AnchorEntity(.head)
            content.add(headEntity)
            
            if let text = attachments.entity(for: "at01") {
                text.position = [0, 0, -0.25]
                headEntity.addChild(text)
            }
                       
        }
        attachments: {
            Attachment(id: "at01") {
                Text("Hello World!")
                    .font(.extraLargeTitle)
                    .padding()              
            }     
        }
    }
}

App.swift

import SwiftUI

@main
private struct App: App {    
    @State var loader = EnvironmentLoader()
    
    public var body: some Scene {
        WindowGroup {
            ContentView()
    }
        
    ImmersiveSpace(id: "AppSpace") { 
        ImmersiveView(loader: loader)
                
    }
    .immersionStyle(selection: .constant(.progressive), in: .progressive)
    }
}
Answered by Vision Pro Engineer in 805836022

Hi @XWDev

Thanks for adding the images. They helped me understand. I did some research and learned that only mixed immersion supports rendering entities (attachments are entities) in front of a window. That is, a window will always obscure an entity in progressive or full immersion. If you'd like support for rendering an entity in front of a window in full or mixed immersion, please file a feature request via feedback assistant and detail your use case. Be sure to focus on the outcome. For example, you may say, "I want to create a heads up display in a fully immersive space", rather than saying, "I want to place an entity in front of a window".

Hi @XWDev

I want to help, but I don't understand the issue. Can you add a screenshot to help me better understand?

Thanks for your quick reply!

So basically, the attachment is currently behind the visible window, but I would like to have it visible in front of the window. If you look at the screenshots, you can see that the "Hello World" attachment will always be behind the window, whether I move the window closer or further away. So, I'm assuming that it is a layering issue within the space?

Accepted Answer

Hi @XWDev

Thanks for adding the images. They helped me understand. I did some research and learned that only mixed immersion supports rendering entities (attachments are entities) in front of a window. That is, a window will always obscure an entity in progressive or full immersion. If you'd like support for rendering an entity in front of a window in full or mixed immersion, please file a feature request via feedback assistant and detail your use case. Be sure to focus on the outcome. For example, you may say, "I want to create a heads up display in a fully immersive space", rather than saying, "I want to place an entity in front of a window".

Attachment layer hidden behind visionOS app window in immersive space
 
 
Q