添加剂混合的正确金属混合选项是什么?

问题描述 投票:0回答:1

我试图在 Metal 中混合源纹理和一些雪花,但我找不到适合我的用例的混合选项。 This is the closest I've gotten to it.

我目前使用的混合选项是:

descriptor.sourceRGBBlendFactor        = MTLBlendFactorSourceAlpha;
descriptor.sourceAlphaBlendFactor      = MTLBlendFactorOne;
descriptor.destinationRGBBlendFactor   = MTLBlendFactorOne;
descriptor.destinationAlphaBlendFactor = MTLBlendFactorOne;

我试过这些.

我希望雪花的蓝色部分与蓝色背景融合,而不是与下面的背景融合。

任何人都可以向我解释我错了什么,正确的公式应该是什么以及我们如何得出它?

objective-c graphics metal blending alphablending
1个回答
0
投票

你的代码遗漏了一些东西。我认为您需要对

add
rgbBlendOperation
进行混合操作。如果你只是想在上面加一片雪花,我想你拥有的因素应该足够了。
如果你看一下

https://developer.apple.com/documentation/metal/mtlblendoperation/add

,它列出了一些公式 alphaBlendOperation

 其中 
RGB = Source.rgb * SBF + Dest.rgb * DBF A = Source.a * SBF + Dest.a * DBF

是源混合因子,

SBF
是目标混合因子。
所以,基本上,要扩展你的情况,

DBF

似乎应该可以解决问题。

© www.soinside.com 2019 - 2024. All rights reserved.