我正在添加 alpha 0.2 的红色。
在重叠区域中,我也希望这些区域的 alpha 为 0.2。现在它以 0.6 的形式出现。我该怎么做建议。目前我的管道描述符是
pipelineDescriptor.colorAttachments[0].isBlendingEnabled = true
pipelineDescriptor.colorAttachments[0].rgbBlendOperation = .add
pipelineDescriptor.colorAttachments[0].alphaBlendOperation = .add
pipelineDescriptor.colorAttachments[0].sourceRGBBlendFactor = .one
pipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = .one
pipelineDescriptor.colorAttachments[0].destinationRGBBlendFactor = .oneMinusSourceAlpha
pipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = .oneMinusSourceAlpha
我需要在管道描述符或着色器中执行吗?
最佳答案
如果您希望最终结果具有与您正在绘制的相同的 alpha,您需要将它们设置为:
pipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = .one
pipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = .zero
这意味着最终的 alpha 将没有来自您正在渲染的目标的贡献。
关于ios - 以相同的 Alpha 混合 Metal ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51739101/