Post not yet marked as solved
Post marked as unsolved with 1 replies, 1,778 views
Hi there!I am trying to render CAMetalLayer with transparent background and i am facing these issues:1) Transparency can only be achieved with renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColor().Other colors with alpha, event MTLClearColor(red: 1, green: 1, blue: 1, alpha: 0) not makes layer transparent.(isOpaque = false, renderPassDescriptor.colorAttachments[0].loadAction = .clear -- used)2)When I'm setting isOpaque to false: very strange color blending begins, dont know how to describe it, but I have triangles with alpha from 1 to 0 on the edges for antialiasing, and blending on this edges (when one figure intersects with other) is not right, though I have blending setting like this:pipelineStateDescriptor.colorAttachments[0].rgbBlendOperation = .add
pipelineStateDescriptor.colorAttachments[0].alphaBlendOperation = .add
pipelineStateDescriptor.colorAttachments[0].sourceRGBBlendFactor = .sourceAlpha
pipelineStateDescriptor.colorAttachments[0].sourceAlphaBlendFactor = .sourceAlpha
pipelineStateDescriptor.colorAttachments[0].destinationRGBBlendFactor = .oneMinusSourceAlpha
pipelineStateDescriptor.colorAttachments[0].destinationAlphaBlendFactor = .oneMinusSourceAlpha
pipelineStateDescriptor.colorAttachments[0].isBlendingEnabled = true, and when i turn isOpaque to on everything goes well. What am I missing?Thanks.