我正在用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
我需要在“管道描述符”中还是在“着色器”中进行此操作?
答案 0 :(得分:1)
如果您希望最终结果具有与绘制相同的Alpha,则需要将它们设置为:
pipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = .one
pipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = .zero
这将意味着最终的Alpha不会对您正在渲染的目标产生任何贡献。