删除金属质感[iOS]

时间:2018-09-20 16:40:47

标签: ios metal

如何使用以下混合参数和管道描述符擦除在屏幕上绘制的金属纹理? “擦除”是指用透明的颜色填充。

混合参数:

renderPipelineDescriptor.colorAttachments[0].isBlendingEnabled = true
renderPipelineDescriptor.colorAttachments[0].rgbBlendOperation = .add
renderPipelineDescriptor.colorAttachments[0].alphaBlendOperation = .add
renderPipelineDescriptor.colorAttachments[0].sourceRGBBlendFactor = .one
renderPipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = .one
renderPipelineDescriptor.colorAttachments[0].destinationRGBBlendFactor = .oneMinusSourceAlpha
renderPipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = .oneMinusSourceAlpha

管道描述符:

descriptor.colorAttachments[0].loadAction = .load
descriptor.colorAttachments[0].clearColor = MTLClearColor(red: 0.0, green: 0.0, blue: 0.0, alpha:0.0)
descriptor.colorAttachments[0].storeAction = .store
descriptor.colorAttachments[0].texture = colorAttachmentTexture

let renderCommandEncoder = commandBuffer.makeRenderCommandEncoder(descriptor: descriptor)
renderCommandEncoder?.setRenderPipelineState( blendRGBAndAlphaPipelineState)
texturedQuad.encodeDrawCommands(encoder: renderCommandEncoder!, texture: texture)
renderCommandEncoder?.endEncoding()

我尝试将sourceRBGBlendFactor和sourceAlphaBlendFactor更改为.zero,但这并未产生所需的擦除效果。

0 个答案:

没有答案