I'm not sure if this is a runtime question exactly, but it seemed like the best place to ask. I've been integrating the spine-c++ runtime into my personal engine. I use Metal to render on iOS. I've exported with pre-multiplied alpha unchecked, and then setup the renderer to match. But I'm still seeing darkness being added wherever there is transparency.

Here's what it looks like in spine (left) vs how it renders in game (right). This guy has a thick glowing semi-transparent border, but for most other assets the issue manifests as a thin black outline.
Screen Shot 2021-09-29 at 8.14.44 AM.png

Here are my texture packer settings:
Screen Shot 2021-09-29 at 8.08.28 AM.png

And here's how my MTLRenderPipelineDescriptor is setup:
blendingEnabled = YES;
rgbBlendOperation = MTLBlendOperationAdd;
alphaBlendOperation = MTLBlendOperationAdd;
sourceRGBBlendFactor = MTLBlendFactorSourceAlpha;
sourceAlphaBlendFactor = MTLBlendFactorSourceAlpha;
destinationRGBBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
destinationAlphaBlendFactor = MTLBlendFactorOneMinusSourceAlpha;

Thanks for any help!
Bu mesaja eklenen dosyaları görüntülemek için gerekli yetkilere sahip değilsiniz.
  • Mesajlar: 6


The artifacts you describe are the reason to use pre-multiplied alpha. Your blend settings are correct for non-PMA, but the artifcats are unavoidable. I suggest you use PMA. Have a look at the WebGL blend state setup for PMA as a reference. These should translate easily to Metal.
Kullanıcı avatarı

  • Mesajlar: 3082


Thanks for the response. I'm still not sure what the problem is exactly, but somehow alphas are getting pre-multiplied after I add the png to my xcode project. A response on an Apple forum mentioned that the "Compress PNG Files" build setting in xcode will modify the png to have pre-multiplied alpha, but I tried setting that to "No" and it didn't help. Anyway, I'm just removing alpha from rgb in the fragment shader for now.

Side note: I had a similar response written out yesterday, but the forum timed-out my login by then so it was deleted. What's with the 1990's behavior on this forum?
  • Mesajlar: 6

Dön Runtimes