Search code examples
metal

Blending operations in Metal


When blending with sourceRGBBlendFactor = sourceAlpha which one alpha value will be taken in formula - original source alpha, calculated in shader or alpha value calculated by sourceAlphaBlendFactor?


Solution

  • It's the original source alpha. You can think of these two calculations (MTLBlendOperationAdd) as occurring concurrently.

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