Puzzled about alpha blending in Canvas
Posted: Tue Jun 14, 2022 9:57 pm
I'm using Tiled to build my maps.
I have layers, each with their own tiles from my tileset and I transcribe that into meshes that I draw later in my game (so each layer is a unique mesh). The list order from Tiled is then my draw order in Love.
Now my issue is that I have a layer which contains tiles with transparent pixels (so not fully opaque or fully transparent, but in-between). Those are shadows and I'm not getting the same result as inside Tiled. I'm wondering if this could be a pre-multiplied alpha issue (or some alike) but I'm not sure.
Here is a comparison: (Left is ingame, right is Tiled.)
As you can see the contrast of the shadows is not the same. Given how I authored the image, Tiled is the expected result (shadow are black squares with an alpha just being a linear gradient).
My layers are drawn in a Canvas, so I tried to play with the love.graphics.setBlendMode but no luck. I'm also have gammacorrect = true, but playing with that didn't help either.
Does anybody have an idea of what else I could try ?
[EDIT] Bonus, additional visuals. This is what the middle tile looks like against a checkered background: If I remove the alpha via my shader, you can see the shadow is pure black:
I have layers, each with their own tiles from my tileset and I transcribe that into meshes that I draw later in my game (so each layer is a unique mesh). The list order from Tiled is then my draw order in Love.
Now my issue is that I have a layer which contains tiles with transparent pixels (so not fully opaque or fully transparent, but in-between). Those are shadows and I'm not getting the same result as inside Tiled. I'm wondering if this could be a pre-multiplied alpha issue (or some alike) but I'm not sure.
Here is a comparison: (Left is ingame, right is Tiled.)
As you can see the contrast of the shadows is not the same. Given how I authored the image, Tiled is the expected result (shadow are black squares with an alpha just being a linear gradient).
My layers are drawn in a Canvas, so I tried to play with the love.graphics.setBlendMode but no luck. I'm also have gammacorrect = true, but playing with that didn't help either.
Does anybody have an idea of what else I could try ?
[EDIT] Bonus, additional visuals. This is what the middle tile looks like against a checkered background: If I remove the alpha via my shader, you can see the shadow is pure black: