Skip to content

qt: use signed distance field based anti aliasing for round rectangle image

Fatih Uzunoğlu requested to merge fuzun/vlc:qt/sdfaa into master

This is essentially what Valve suggests in the whitepaper "Improved Alpha-Tested Magnification for Vector Textures and Special Effects" (https://dl.acm.org/doi/10.1145/1281500.1281665). I have used the signed distance function for rounded box provided by Inigo Quilez, here: https://iquilezles.org/articles/distfunctions2d.

We don't need to precalculate the distance field, because it is really trivial for a rounded rectangle. I calculate the distance within the fragment shader directly.

This is draft because for some reason atlas texture does not work at the moment. This should be corrected now.

MSAA with custom geometry should still be better, as blending would not be required in that case, and it would also sample less from the texture because the defined geometry itself is smaller. But, we can use this as an alternative when there is no MSAA. It is debatable if we should request MSAA ourselves, or not.

Signed distance field + smoothstep (softEdgeMin = 0.01, softEdgeMax = -0.01):

image

Current approach (QPainter + QPainter::Antialiasing):

image

  • Batching should be fine, considering atlas textures are supported now, and the custom uniform values should be equal between the delegate instances.

Request review @chub.

Edited by Fatih Uzunoğlu

Merge request reports

Loading