dragonikpl

After few days of hard work and trying to grasp my head around Apple's Metal, I finally managed to integrate spine C runtime into SpriteKit framework! I based my code on cocos2d runtime, but rewrote it in Swift. Rendering is based on meshes that C runtime generates. Here's a demo running on iPhone X backed by SpriteKit :grinteeth:



After I am happy with results and clean up my code, I will post source code to github (and add it to this thread).
dragonikpl
  • 記事: 3

Nate

Cool! 8)

BTW, the dark outlines look like a PMA problem.
アバター
Nate

Nate
  • 記事: 9491

dragonikpl

I cannot grasp my head around PMA - I am getting those black borders around textures.

This is my blend mode for premultipliedAlpha flag set to true:
source alpha = .one
destination alpha = .oneMinusSourceAlpha
source color = .one
destination color = .oneMinusSourceAlpha
Blending operations are set to add.

Any ideas where to look why it doesn't work properly?


Rendering without PMA looks nice.
Zrzut ekranu 2020-01-27 o 18.09.38.png
添付ファイルを見るにはパーミッションが必要です
dragonikpl
  • 記事: 3

Nate

Those blending modes look right for PMA. Those plus an atlas that was created with PMA should give you the correct results. Could it be something in your toolchain is wrecking your images? In the past, Apple tools have been known to apply PMA!
アバター
Nate

Nate
  • 記事: 9491

plament

Recently I've implemented Metal rendering using the C++ runtime and had some issues with PMA. Seems PMA is always applied on the textures when building on the device and is not when building on the Simulator. Here is my Metal blending setup:
pipelineStateDescriptor.colorAttachments[0].blendingEnabled = YES;
pipelineStateDescriptor.colorAttachments[0].rgbBlendOperation = MTLBlendOperationAdd;
pipelineStateDescriptor.colorAttachments[0].alphaBlendOperation = MTLBlendOperationAdd;
#if TARGET_IPHONE_SIMULATOR
pipelineStateDescriptor.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorSourceAlpha;
#else
pipelineStateDescriptor.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorOne;
#endif
pipelineStateDescriptor.colorAttachments[0].sourceAlphaBlendFactor = MTLBlendFactorSourceAlpha;
pipelineStateDescriptor.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
pipelineStateDescriptor.colorAttachments[0].destinationAlphaBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
Also I needed to set MTKTextureLoaderOptionSRGB : @NO when loading the textures in my TextureLoader
plament
  • 記事: 10

dragonikpl

Thanks for a reply @plament, I applied your findings, but it is still rendering incorrectly. I had SRGB option set to NO.
dragonikpl
  • 記事: 3

plament

Have you tried to create the atlas without PMA enabled?
plament
  • 記事: 10


Return to Runtimes