5 ms·
Pathfinder 2 is now mostly a CPU approach with very little done on the GPU, because you really want to avoid late-Z. I don't know of anybody else doing state-of
by Jasper_ 8y ago
Pathfinder 2 is now mostly a CPU approach with very little done on the GPU, because you really want to avoid late-Z. I don't know of anybody else doing state-of-the-art GPU vector rasterization. Slug has the same pitfalls as Pathfinder 1 (late-Z & overdraw) and also requires an expensive preprocessing step.
I don't think distance fields are the correct approach either, though the work that Adam Simmons is doing to analytically solve beziers on the GPU is interesting: https://twitter.com/adamjsimmons/status/730911372532322304 https://twitter.com/adamjsimmons/status/730911372532322304
- adamjs 8y agoI actually moved all of that to the CPU (parallel, SIMD) and am using it in Ultralight [1] to generate high-precision SDFs for font-glyphs and small paths. I'll release the GPU-based implementation when I have more time. If you're interested in the details of the GPU-based implementation, I pre-sort the path data into bins on CPU, encode it to a dynamic texture, traverse the structure in shader using a modified BVH, and calculate the exact distance to individual Beziers using root finding, which I open-sourced here [2]. It's very fast and avoids overdraw through the use of a low-res stencil mask also encoded into texture. There's of course a lot more nuance than that (fill calculation, level-of-detail, etc.) but that's for a long blog post. - [1] https://ultralig.ht https://ultralig.ht - [2] https://www.shadertoy.com/view/ltXSDB https://www.shadertoy.com/view/ltXSDB
- Lerc 8y agoOoh! thanks for the shadertoy link. I'd been struggling with how to do my curved shapes for my evolver. http://blag.fingswotidun.com/2016/05/evolved-images-using-shader-peliminary.html http://blag.fingswotidun.com/2016/05/evolved-images-using-sh...
- adamjs 8y agoLooks neat! Glad to help.
- Jasper_ 8y agoI'm most curious how you're generating a sharp SDF in realtime. Are you just using the pseudo-SDF as recommended by Qin et. al?
- adamjs 8y agoBit hard to explain without examples but while traversing the beziers in shader, I test if we are equidistant to two or more beziers and do special handling to merge the two unclamped fields (normally we clamp 't' between [0, 1] when sampling bezier distance, but for merging two fields we can project it infinitely and then select closest).
- Const-me 8y ago> Slug has the same pitfalls as Pathfinder 1 (late-Z & overdraw) Are you sure about that? I’ve looked at their demo with renderdoc. They’re rendering a small polygon for each character, i.e. they’re rejecting invisible characters, or parts of characters, early before PS. And because they cut corners of each character the overdraw is minimized as well. Symmetric band optimization further reduces time spend computing the PS.