OGeek|极客世界-中国程序员成长平台

标题: ios - 当笔画在 Metal 中相互交叉时混合 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 20:26
标题: ios - 当笔画在 Metal 中相互交叉时混合

我绘制以固定间隔重叠的小方 block ,这样感觉就像在绘图应用程序中的纹理刷。

目前我使用管道描述符

pipelineDescriptor.colorAttachments[0].rgbBlendOperation = .add
pipelineDescriptor.colorAttachments[0].alphaBlendOperation = .add
pipelineDescriptor.colorAttachments[0].sourceRGBBlendFactor = .sourceAlpha
pipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = .one
pipelineDescriptor.colorAttachments[0].destinationRGBBlendFactor = .oneMinusSourceAlpha
pipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = .oneMinusSourceAlpha

我的目标是当两个笔画相互交叉时,我想在 OpenGL 中添加一种类似于混合模式的白色

我附上了一张我目前得到的照片。

enter image description here

当斯托克斯交叉时,它应该显示为白色。

建议一种实现方式



Best Answer-推荐答案


您似乎没有在 MTLRenderPipelineColorAttachmentDescriptor 上设置 blendingEnabled 属性。此外,请确保您使用的是 sRGB 纹理,以便采样器知道如何在混合时将 8 位值解码为线性光。

关于ios - 当笔画在 Metal 中相互交叉时混合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51701272/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4