On Sun, Jun 28, 2020 at 10:18 AM Anuj Verma <[email protected]> wrote: > Apart from that, I thought about another optimization: > Smooth rasterizer is ultra fast, it only takes a few nano- > seconds to render. So we can embolden the outline by > spread, render it with the smooth or monochrome rasterizer > and that will give us all the points that we need to check. It > can pair up well with the bounding box method.
Unfortunately, the emboldening algorithm has flaws... The stroker is probably a bit more reliable but is much slower too. The smooth renderer performance is a good benchmark to aspire to and I think that the SDF renderer can be within reach. The distance to a line is a cross product divided by the line length ignoring the distances to the ends for a moment. The division by the length is the same for all grid points in the neighborhood so it can be reused as inverse length. The cross products are also interesting: they turn out to be incremental from grid to grid point. Combining the two facts, it is super fast to fill the neighborhood of a line using a single division. Now you just have to deal with the ends trivially. That is why I think that ultimately dividing the curves will win and the performance will be comparable to the smooth renderer. Best, Alexei
