3 ms·
I've done a library for vector graphics on the GPU which works pretty well for my uses: https://github.com/audulus/vger https://github.com/audulus/vger and a
by tayistay 4y ago
I've done a library for vector graphics on the GPU which works pretty well for my uses:
https://github.com/audulus/vger https://github.com/audulus/vger
and a rust version:
https://github.com/audulus/vger-rs https://github.com/audulus/vger-rs
(which powers my rust GUI library: https://github.com/audulus/rui https://github.com/audulus/rui)
Here's the approach for rendering path fills. From the readme:
> The bezier path fill case is somewhat original. To avoid having to solve quadratic equations (which has numerical issues), the fragment function uses a sort-of reverse Loop-Blinn. To determine if a point is inside or outside, vger tests against the lines formed between the endpoints of each bezier curve, flipping inside/outside for each intersection with a +x ray from the point. Then vger tests the point against the area between the bezier segment and the line, flipping inside/outside again if inside. This avoids the pre-computation of Loop-Blinn, and the AA issues of Kokojima.
It works pretty well, and doesn't require as much preprocessing as the code in the article. Also doesn't require any GPU compute (though I do use GPU compute for some things). I think ultimately the approach in the article (essentially Piet-metal, aka tessellating and binning into tiles) will deliver better performance, and support more primitives, but at greater implementation complexity. I've tried the Piet-metal approach myself and it's tricky! I like the simpler Shadertoy/SDF inspired approach :)