Setting up the project structure and the Metal rendering pipeline
It appears that you are using premultiplied alpha blending, but it looks like the colors you're sending to the GPU are not premultiplied, unless I missed something.
I don't know. I'm a total beginner when it comes to graphics APIs.
Which part of the code sets up the premultiplied alpha blending?
color_attachment_desc->setSourceRGBBlendFactor(.One) is premultiplied,
color_attachment_desc->setSourceRGBBlendFactor(.SourceAlpha) is straight alpha.
In the OpenGL version you used straight alpha blending.
I fixed that part in the newest post. Not sure it has anything to do with the alpha being premultiplied though.
If you use .One and then in the shader you do this:
color.r *= color.a;
color.b *= color.a;
color.g *= color.a;
Then you should get the same blending as using .SourceAlpha. If not, then .One wasn't using premultiplied alpha blending.
It appears that you are using premultiplied alpha blending, but it looks like the colors you're sending to the GPU are not premultiplied, unless I missed something.
I don't know. I'm a total beginner when it comes to graphics APIs.
Which part of the code sets up the premultiplied alpha blending?
color_attachment_desc->setSourceRGBBlendFactor(.One) is premultiplied,
color_attachment_desc->setSourceRGBBlendFactor(.SourceAlpha) is straight alpha.
In the OpenGL version you used straight alpha blending.
I fixed that part in the newest post. Not sure it has anything to do with the alpha being premultiplied though.
If you use .One and then in the shader you do this:
color.r *= color.a;
color.b *= color.a;
color.g *= color.a;
Then you should get the same blending as using .SourceAlpha. If not, then .One wasn't using premultiplied alpha blending.