Sub-pixel distance transform
acko.net
acko.net
> In this post I will describe Use.GPU's text rendering, which uses a bespoke approach to Signed Distance Fields (SDFs). This was borne out of necessity: while SDF text is pretty common on GPUs, some of the established practice on generating SDFs from masks is incorrect, and some libraries get it right only by accident. So this will be a deep dive from first principles, about the nuances of subpixels.
High quality font rendering for WebGPU
(but then it's not really about WebGPU either but about solving general problems with SDF font generation and rendering)
Amazing that we have a unicode code point for this, but we still need to use vegetables as proxies for our reproductive organs.
Look at that subtle off-white coloring. The tasteful thickness of it. Oh my God, it even has a novel distance transform...
It seems like you could use the sun pixel distances like he did, but then use them with jump fill, but maybe I'm missing something?
GPUs aren't universally supported by browsers or available on client devices, and implementing a user-agent/telemetry based response adds overhead.
Also the distance transform algorithm in the article could be implemented on a GPU using a thread per row & column rather than per pixel. (At least in CUDA - I’m not immediately certain how to do it in GLSL but I guess someone could do it.) This is not optimal, of course, but parallelizing rows is perhaps a lot better than a single-threaded loop over the image.
Here are a few that predate and I think make the same observation:
https://dl.acm.org/doi/10.1016/j.ipl.2006.12.005
https://www.sciencedirect.com/science/article/abs/pii/002001...
That second paper from 1996 references an even older paper from 94, saying “Dividing rows and columns alternately, Chen and Chuang reduced the time complexity to O(N^2) which is optimal.”
https://www.sciencedirect.com/science/article/abs/pii/002001...
[1] https://en.wikipedia.org/wiki/Cubic_equation#Trigonometric_s...
[2] https://en.wikipedia.org/wiki/Cubic_equation#Geometric_inter...