Comment by Lichtso

Comment by Lichtso 13 hours ago

2 replies

> The distance is only irrelevant for plain 2D text rendering, right?

Yes, as I said it is relevant for text rendering, but not necessarily 2D. It can also be embedded in a 3D perspective as long as the text itself is planar. Meaning you can directly render text in a 3D scene this way without rendering to a texture first.

> But real shadows and lighting would require the distance aspect, no?

I think the difference is in stroke vs fill, not the illumination (as you could still use shadow mapping / projection). In stroking you need to calculate an offset curve either explicitly or implicitly sample it from a signed distance field. Thus the exact distance matters for stroking, for filling it does not.

vlovich123 12 hours ago

Couldn’t you do stroking by doing a second fill operation on a slightly scaled down version of the first with the negative space color as the interior?

  • Lichtso 12 hours ago

    Yep, stroking is just filling of the space between offset curves (aka. parallel curves), and that "slightly scaled down version of the first" is the "calculate an offset curve explicitly" approach I mentioned.

    Though it is very unpractical because the offset curve of a cubic bezier curve is not a cubic bezier curve anymore, instead it is an analytic curve of degree 10. Thus, in practice the offset curves for stroking are either approximated by polygons or implicitly sampled from signed distance fields.

    Raph Levien has a good blog post about it:

    https://raphlinus.github.io/curves/2022/09/09/parallel-bezie...

    One more thing: Offset curves are different form classical scaling from a center point in all but the most trivial cases where there exists such a center; namely regular polygons. And cubic bezier curves can be concave, even have a self intersecting loop or form a cusp.