Metal pre-multiplies alpha on iOS but not macOS?

Hi!

I'd just like to know if what we are seeing is correct, and if there is a way to change this behavior.


It looks like whenever we load a PNG using MTKTextureLoader, the resulting pixels are pre-multiplied with alpha on iOS, but NOT on macOS...


Is this correct? This has caused all sorts of mayhem and time lost. Is there an option somewhere to make the behavior consistent one way or the other?


Thank you!

Accepted Reply

I think the problem probably lies with the XCode packaging options rather than the Metal API.


There's an option in `Build Settings`->`Compress PNG Files - Packaging` called `Compress PNG Files` which recompresses your PNG files with a custom version of PNGCrush, amongst other things (switching to BGRA IIRC), it premultiplies the alpha.

Replies

I think the problem probably lies with the XCode packaging options rather than the Metal API.


There's an option in `Build Settings`->`Compress PNG Files - Packaging` called `Compress PNG Files` which recompresses your PNG files with a custom version of PNGCrush, amongst other things (switching to BGRA IIRC), it premultiplies the alpha.

Wow, thank you that sounds right!