Hi, I try to use CAMetalLayer to render a page on VisionOS, but the transparency of CAMetalLayer seems not displayed correctly. As the picture shown, the square background should be transparent, but it's not.
I have set the PipelineDescriptor and RenderPassDescriptor like this:
let pipelineDescriptor = MTLRenderPipelineDescriptor()
pipelineDescriptor.colorAttachments[0].pixelFormat = .bgra8Unorm
pipelineDescriptor.colorAttachments[0].isBlendingEnabled = true
pipelineDescriptor.colorAttachments[0].rgbBlendOperation = .add
pipelineDescriptor.colorAttachments[0].alphaBlendOperation = .add
pipelineDescriptor.colorAttachments[0].sourceRGBBlendFactor = .sourceAlpha
pipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = .sourceAlpha
pipelineDescriptor.colorAttachments[0].destinationRGBBlendFactor = .oneMinusSourceAlpha
pipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = .oneMinusSourceAlpha
let descriptor = MTLRenderPassDescriptor()
descriptor.colorAttachments[0].texture = texture
descriptor.colorAttachments[0].loadAction = .clear
descriptor.colorAttachments[0].clearColor = MTLClearColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0)
descriptor.colorAttachments[0].storeAction = .store
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I run the immersive app rendered by Metal (here is code), and found that the background of the window and keyboard black is black, as picture shown. I have several questions about it.
Can you explain why it is happening in terms of rendering mechanism?
Can the background be configured in other colors, such as semi-transparent, white?
Do you recommend using Window scene in fully immersive application using Compositor Service?
thanks.