Open tronical opened 3 years ago
My guess as to the issue is that you're not using premultiplied alpha for blending, so halfway between rgba(0, 0, 0, 0)
and rgba(0, 255, 0, 1)
is blended as "draw halfway between black and green, with alpha halfway between 0 and 100%" rather than "draw green with 50% alpha".
Another possibility for improving gradients is using gamma-corrected blending for gradients. This produces more consistent brightnesses (halfway through a gradient is the same brightness as a checkerboard, blending from red to green isn't darker in the middle). The downside is that it makes black-white linear gradients lighter in the middle than expected. Unfortunately this shouldn't be implemented, because browsers blend in sRGB gamma space rather than linear.
Thank you @nyanpasu64!! What you’re saying about the lack of premultiplied alpha makes sense just looking at the fragment shader in femtovg. I’ll take a look on Monday.
We have more renderer now.
The Qt and software renderer agree, and Skia and Femtovg also agree
But who is right?
I think Qt and software is right. Skia and FemtoVG show some "gray" color which seems coming from the pixel value of the transparent pixel. (which is black with 0 alpha)
Yes, Qt and software renderer are right IMO - they're interpolating pre-multiplied colors and there's no grey.
Related femtovg issue: https://github.com/femtovg/femtovg/issues/16
The following minimal test-case produces different rendering with femtovg and Qt:
Ideally they are rendered the same.
Screenshots to illustrate: