This is a nice use of MetaPost and the figures look elegant! The shading and textures seems to be a Russian aesthetic, as it reminds me of Irodov and other Mir Publishers books from my childhood in India.
For those who may not know much about MetaPost, it was originally written by Donald Knuth's student John Hobby, to a great extent based (both syntax and code of the program itself) on METAFONT, written by Knuth for designing fonts, as the companion to TeX. The idea is to describe shapes—either shapes of letters (glyphs in the typeface) in case of METAFONT, or other shapes in case of MetaPost—by telling the computer how to draw them, i.e. writing a program that describes the shape. The program automatically computes intersections of lines, joins points using “most pleasing curves” (Hobby splines), etc. See for example Figure 6 in this post whose code is simply
It's really a fantastic way to draw for certain people, but it requires you to think about the shape to a greater level of detail (enough to write a program basically) than simply drawing it, so it's not for everyone. The syntax of other similar programs like TikZ and Asymptote has also been greatly influenced by that of METAFONT/MetaPost.
BTW the author of this post here (jemmybutton / Sergey Slyusarev) is also the author of [Fancy Euclid's “Elements” in TeX] that was posted here a while ago: https://news.ycombinator.com/item?id=20019616
Not sure about signed distance fields in particular, but in general you need two things: some kind of "lightness" at any given point and stroke direction at the same point. The former should be doable with signed distance fields, the latter doesn't seem to be something that you can always calculate: note that hatches along "tubes" are as valid in that style as hatches across "tubes" and as valid as some diagonal, curly and whatnot would be. If you don't care all that much about hatches direction, you can definitely get something similar to one of many "woodcut" filters for graphics software, but currently there's no special tool for that in this library.
For realistic rendering with signed distance functions, you already need to know certain material properties at each point such as color, specularity, reflectivity and so on. "Hatch direction" could simply be specified as one of those properties.
I see the greater hurdle in marrying the sampling-based nature of SDF rendering with MetaPost's vector graphics. You'd probably need a rasterized image at high resolution (which includes the "hatch direction" information for each pixel) and then approximate it with vector strokes.
If you do have such data, it should be possible. At least in theory. In practice, yes, probably the easiest way would be to have a flat image with depth (or "lightness") and hatch direction information processed by MetaPost somehow. What the library is missing now, is an algorithm which would convert some arbitrary field of directions into actual hatches: the problem is that you need to have more or less uniform "black" without too "dense" or too "loose" areas; this problem in this library is solved for some particular cases (when tube width changes, the number of strokes also changes in order to keep approximately the same stroke density, for example), but the general solution with reasonable results is probably much trickier.
With all that said, MetaPost probably isn't the best tool to deal with "real" 3D problems, and implementing (and re-implementing) these algorithms in some conventional 3D software could be a better option.
For those who may not know much about MetaPost, it was originally written by Donald Knuth's student John Hobby, to a great extent based (both syntax and code of the program itself) on METAFONT, written by Knuth for designing fonts, as the companion to TeX. The idea is to describe shapes—either shapes of letters (glyphs in the typeface) in case of METAFONT, or other shapes in case of MetaPost—by telling the computer how to draw them, i.e. writing a program that describes the shape. The program automatically computes intersections of lines, joins points using “most pleasing curves” (Hobby splines), etc. See for example Figure 6 in this post whose code is simply
after the author has defined the sphere.c function (macro) with shading and shadows etc (https://github.com/jemmybutton/fiziko/blob/2ccb6e1/fiziko.mp...).It's really a fantastic way to draw for certain people, but it requires you to think about the shape to a greater level of detail (enough to write a program basically) than simply drawing it, so it's not for everyone. The syntax of other similar programs like TikZ and Asymptote has also been greatly influenced by that of METAFONT/MetaPost.
BTW the author of this post here (jemmybutton / Sergey Slyusarev) is also the author of [Fancy Euclid's “Elements” in TeX] that was posted here a while ago: https://news.ycombinator.com/item?id=20019616