How to make the Swift UI window display the frosted glass effect normally in the metal immersive space

I used metal and CompositorLayer to render an immersive space skybox. In this space, the window created by the Swift UI I created only displays the gray frosted glass background effect (it seems to ignore the metal-rendered skybox and only samples and displays the black background). why is that? Is there any solution to display the normal frosted glass background? Thank you very much!

Replies

this is my code:

@main
struct SwiftUItest: App {
    init() {}
    
    var body: some Scene {

	//...

	ImmersiveSpace(id: "ImmersiveSpace"){
            CompositorLayer(configuration: ContentStageConfiguration()){ layerRenderer in
                Renderer(layerRenderer: layerRenderer)
	//CompositorLayer is a necessary layer for loading metal in vision os.
            }
            
        }
}
class Renderer: NSObject {
 	public init(layerRenderer: LayerRenderer, sceneData: SceneData) {
        	self.layerRenderer = layerRenderer
        	super.init()
        	startRenderLoop()
      }

	func startRenderLoop() {
        	Task {
            		do {
                		openWindow(id:"origin window")//Open swift ui window
                		try await arSession.run([worldTracking])
            		} catch {
                		fatalError("Failed to initialize ARSession")
            		}
            		let renderThread = Thread {
 				while true {
					//metal rendering model

					//....

					guard let encoder = commandBuffer.makeRenderCommandEncoder(descriptor: renderPassDescriptor) else { return }
					 scene.originSkyBox.update(drawable)
              				scene.originSkyBox.render(encoder: encoder)
					encoder.endEncoding()
          
          				drawable.encodePresent(commandBuffer: commandBuffer)
          				commandBuffer.commit()
          				// --------- end render a frame
          
          				frame.endSubmission()
				}
                		 
            		}
            		renderThread.name = "RenderThread"
            		renderThread.start()
        	}
	}
}

I hope someone can help me solve this problem,Thanks