Crates.io | vger |
lib.rs | vger |
version | 0.4.0 |
source | src |
created_at | 2022-03-24 20:29:38.094598 |
updated_at | 2024-09-07 00:36:12.027114 |
description | 2D GPU renderer for dynamic UIs |
homepage | |
repository | https://github.com/audulus/vger-rs |
max_upload_size | |
id | 555910 |
size | 296,943 |
vger is a vector graphics renderer which renders a limited set of primitives, but does so almost entirely on the GPU. Port of VGER to Rust. Used in rui.
I was previously using nanovg for Audulus, which was consuming too much CPU for the immediate-mode UI. nanovg is certainly more full featured, but for Audulus, vger maintains 120fps while nanovg falls to 30fps on my 120Hz iPad because of CPU-side path tessellation, and other overhead. vger renders analytically without tessellation, leaning heavily on the fragment shader.
vger draws one or more quads for each primitive and computes the actual primitive shape in the fragment function with an SDF. For path fills, vger splits paths into horizontal slabs (see path.rs) to reduce the number of tests in the fragment function.
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.