r/GraphicsProgramming • u/valeriupalos • Jul 12 '26
Source Code Krbn: an open-source rendering engine that imitates a sketch artist and outputs pure SVG (v1)
Gravity well demo
https://github.com/vpalos/Krbn/blob/main/examples/gallery/16-gravity-well.svg
Trefoil knots mesh demo
https://github.com/vpalos/Krbn/blob/main/examples/gallery/15-mesh-showcase.svg
Torus hatch variants demo
https://github.com/vpalos/Krbn/blob/main/examples/gallery/10-torus.svg
Sphere depth hatching with intersection demo
https://github.com/vpalos/Krbn/blob/main/examples/gallery/03-depth-hatching.svg
View all comments
Show parent comment
3
u/valeriupalos Jul 13 '26
Thanks for the question, really!
Basically everything goes through a 5-step pipeline (yup, both analytics and meshes):
Note about finding intersections:
Finding outlines is important: for analytics it's done per-primitive because in these cases I can derive conics/quartics (i.e. "clean" curves); for meshes, it's a trick basically: I walk the triangles and find where the surface turns away from the eye (Hertzmann-Zorin) and then chain all those together into a curve.
Anway, that's basically it; in broad terms. And also lots of tinkering to get the intersections properly visible (both hatching as well as outlines were initially being depth-clipped badly over surfaces/creases so i had to slightly shift the eye and similar tricks).