I used the ChatGPT feature in Xcode to suggest change to improve my alpha blending, and it suggested I add the following to my MakePipeline function: func makePipeline() { let library = device.makeDefaultLibrary() let pipelineDesc = MTLRenderPipelineDescriptor() pipelineDesc.vertexFunction = library?.makeFunction(name: vertex_main) pipelineDesc.fragmentFunction = library?.makeFunction(name: fragment_main) pipelineDesc.colorAttachments[0].pixelFormat = .bgra8Unorm // ---- New changes // Enable blending for transparent drawing pipelineDesc.colorAttachments[0].isBlendingEnabled = true pipelineDesc.colorAttachments[0].rgbBlendOperation = .add pipelineDesc.colorAttachments[0].alphaBlendOperation = .add pipelineDesc.colorAttachments[0].sourceRGBBlendFactor = .sourceAlpha pipelineDesc.colorAttachments[0].destinationRGBBlendFactor = .oneMinusSourceAlpha pipelineDesc.colorAttachments[0].sourceAlphaBlendFactor = .sourceAlpha pipelineDesc.colorAttachments[0].destinationAlphaBlendFactor = .oneMinusSourceAlpha //
Topic:
Graphics & Games
SubTopic:
Metal
Tags: