Live data from Hacker News

Fast calculation of the distance to cubic Bezier curves on the GPU

blog.pkh.me

1–10 of 37 posts

Re: Fast calculation of the distance to cubic Bezier curves on the GPU

#5
> The next step is to work with chains of Bézier curves to make up complex shapes (such as font glyphs). It will lead us to build a signed distance field. This is not trivial at all and mandates one or several dedicated articles. We will hopefully study these subjects in the not-so-distant future.

If you only want to fill a path of bezier curves (e.g. for text rendering) you can do without the "distance" part from "signed distance field" [0], leaving you with a "signed field" aka. an implicit curve [1].

Meaning not having to calculate the exact distance but only the sign (inside or outside) can be done without all the crazy iterative root finding in an actually cheap manner with only four multiplications and one addition per pixel / fragment / sample for a rational cubic curve [3].

[0]: https://en.wikipedia.org/wiki/Signed_distance_function

[1]: https://en.wikipedia.org/wiki/Implicit_curve

[2]: https://github.com/Lichtso/contrast_renderer/blob/a189d64a13...

Re: Fast calculation of the distance to cubic Bezier curves on the GPU

#7
post #5

> The next step is to work with chains of Bézier curves to make up complex shapes (such as font glyphs). It will lead us to build a signed distance field. This is not trivial at all and mandates one or several dedicated articles. We will hopefully study these subjects in the not-so-distant future. If you only want to fill a path of bezier curves (e.g. for text rendering) you can do without the "distance" part from "s…

Finding the sign of the distance has been extremely challenging to me in many ways, so I'm very curious about the approach you're presenting. The snippet you shared has a "a³-bcd ≤ 0" formula which is all I get without more context. Can you elaborate on it or provide resources?

The winding number logic is usually super involved, especially when multiple sub-shapes start overlap and subtracting each other. Is this covered or orthogonal to what you are talking about?

Re: Fast calculation of the distance to cubic Bezier curves on the GPU

#8
Last time I found a paper in Graphics Gems titled Solving the Nearest-Point-on-Curve Problem, which transforms the problem into a Bernstein polynomial form. Then an exact solution can be obtained using A Bézier Curve-Based Root-Finder. This is my implementation [1], but it's not very robust for high-degree cases.

[1] https://github.com/Long0x0/distance-to-bezier

Re: Fast calculation of the distance to cubic Bezier curves on the GPU

#9
Possibly naive question, but at least in the context of using distance fields to store font glyphs, what's the cost of the analytical solution (distance field of N combined bezier curves) vs rasterize at "high enough" resolution and then perform jump flood

Re: Fast calculation of the distance to cubic Bezier curves on the GPU

#10
post #8

Last time I found a paper in Graphics Gems titled Solving the Nearest-Point-on-Curve Problem , which transforms the problem into a Bernstein polynomial form. Then an exact solution can be obtained using A Bézier Curve-Based Root-Finder . This is my implementation [1], but it's not very robust for high-degree cases. [1] https://github.com/Long0x0/distance-to-bezier

Your link 404s- private repo?
Post reply on HN