9 ms·
A Decade of Slug
https://web.archive.org/web/20260317185928/https://terathon.com/blog/decade-slug.html https://web.archive.org/web/20260317185928/https://terathon....
- miloignis 7mo agoThis is wonderful news, and my sincere thanks to the author. I remember coming upon this algorithm several years ago, and thinking it was extremely elegant and very appealing, but being disappointed by the patent status making it unusable for FOSS work. I really appreciate the author's choice to dedicate it to the public domain after a reasonable amount of time, and congratulations on the success it had while proprietary! Now if I ever get around to writing that terminal emulator for fun, I'll be tempted to do it with this algorithm for the code's aesthetic appeal.
- actionfromafar 7mo agoSoftware patents valid for 8 years is actually something I could get behind.
- deleted 7mo ago[deleted]
- teaearlgraycold 7mo agoCopyrights universally dropped to ~20 years as well while we're at it.
- dhosek 7mo agoMy feeling is that copyrights should be infinitely renewable, with say a 20 year term, but the renewal fee should double with each term so that Disney can have their infinite copyright on Snow White but at an ever-increasing cost so that they will need to make a decision about whether it makes sense to keep it. My utopian vision: First registration is free and automatic. Copyright holders get an automated notification of expiring copyright and renewal is, say $1000 for the first term (adjusting for inflation) and doubling thereafter (also adjusting for inflation, so you don’t get a $2000 renewal but more like $4400 with 4% inflation). For corporate-held and posthumous extensions, the term would be 10 years.
- nicoburns 7mo ago> so that Disney can have their infinite copyright on Snow White If copyright was inifinite, then Disney would never have been able to make Snow White in the first place. They didn't invent the story! Even if they did, it seems like a huge negative to society for copywright not to expire.
- dhosek 7mo agoThe thing here is the exponentially increasing cost of renewing the copyright, with the inflation-adjustment I proposed and the 10-year term for a corporate or posthumous copyright, in 90 years, that $1000 renewal fee goes to $256000 in inflation-adjusted dollars. 110 years it’s a million dollars, 210 years it’s a billion dollars. If a work is worth spending that kind of money on renewing the copyright, why not let them keep it?
- olejorgenb 7mo ago> I was granted a patent for the Slug algorithm in 2019, and I legally have exclusive rights to it until the year 2038. But I think that’s too long. The patent has already served its purpose well, and I believe that holding on to it any longer benefits nobody. Therefore, effective today, I am permanently and irrevocably dedicating the Slug patent to the public domain.
- convexhulled 7mo agoYes, now that SDF font rendering is the industry's preference, he drops the software patent. That is, he is dropping the patent because it isn't a commercially viable piece of software, not because he is ethically opposed to it. Great virtue signaling though.
- ZeWaka 7mo agoYou do realize he could've just kept it until 2038, right? This was completely unforced.
- dwroberts 7mo agoSeems more like he had the patent long enough to build a sustainable business from his own work, and now he’s been able to earn enough from it that others’ implementations aren’t a risk to him. Which is kind of the entire point of patents, just that they last way too long relative to the speed of technological progress
- usefulcat 7mo agoHe said "holding on to it any longer benefits nobody", implicitly including himself. He may believe that it's to his advantage for the patent to be more widely used. Which makes sense--I don't doubt that he is a subject matter expert where this patent is concerned. If this algorithm continues to be widely used or its use increases, then that would be likely be good for him.
- skullt 7mo agoSDF font rendering has been around 20+ years though? Valve really popularized in their 2007 SIGGRAPH paper and Chlumský developed MSDF font rendering in a 2015 thesis.
- moralestapia 7mo agoThank you for your service!
- VikingCoder 7mo agoIs it on ShaderToy yet? :D
- rrauenza 7mo agoHere's an alternate if you're also getting connection reset errors: https://web.archive.org/web/20260317185928/https://terathon.com/blog/decade-slug.html https://web.archive.org/web/20260317185928/https://terathon....
- dang 7mo agoWe'll put that link in the toptext as well. Thanks!
- byearthithatius 7mo agoLove it when someone who makes complex, helpful software is rewarded for their efforts. More stories like this!
- forrestthewoods 7mo agoOh wow this is crazy. This was a project that was reasonably successful commercially. And now it’s just being given away open source? What an absolutely incredibly gift to the community!!
- aseipp 7mo agoNot quite, just the pixel/vertex shaders and the algorithm is public domain. Slug "the software package" is not open source (you can get a copy of it along with C4 Engine for $100 to take a peek if you want, though).
- Vipitis 7mo agoI am sorta in a position where implementing a glyph renderer as a compute shader would be helpful. This is a great opportunity to use this as a reference... exciting weekend project!
- cachius 7mo agoHis latest project is https://radicalpie.com/ https://radicalpie.com/ A Professional Equation Editor for Windows 10/11 for 60$ that uses Slug for rendering. Presumably he‘s using it to write his great FGED books.
- amluto 7mo ago25 years ago I would have loved that. But I don't actually know many people still doing any of this sort of work on Windows. (I get it. It's an awesome replacement for MathType. It uses OLE so that it embeds in Microsoft Word nicely. Still...)
- mmooss 7mo agoWhat stack are those people using?
- kibibu 7mo agoHe has a post up: https://terathon.com/blog/radical-pie.html https://terathon.com/blog/radical-pie.html I'm pretty confident the "stack" is C++ on Win32, with a bunch of hand-rolled libraries and no stdlib.
- mmooss 7mo agoHmmm ... the GP says > I don't actually know many people still doing any of this sort of work on Windows.
- swiftcoder 7mo agoLengyel continues to be standup dude, kudos!
- Cthulhu_ 7mo agoDamn, I worked with the author's game engine (C4) about... 20 years ago now while still in school, didn't know they were still active in that area!
- maximilianburke 7mo agoAmazing! Thank you, Eric!
- leecommamichael 7mo agoThank you!
- lacoolj 7mo ago> But I think that’s too long. The patent has already served its purpose well, and I believe that holding on to it any longer benefits nobody. Damn dude didn't you pay like ... over $10k for that patent?
- elengyel 7mo agoI took care of the whole thing myself without lawyers, so I ended up paying something like $950 in various filing fees.
- kzrdude 7mo agoHow did you get that diploma/plaque, is that something every patent author will have?
- shrubble 7mo agoYou can buy them from various manufacturers that make them; you often get unsolicited mail from them as your name and address is on the patent filings.
- elengyel 7mo agoThe plaque was a personal order from one of the many companies that make them. What you actually get from the USPTO looks like this: https://x.com/EricLengyel/status/1159917092331642880/photo/1 https://x.com/EricLengyel/status/1159917092331642880/photo/1
- astroalex 7mo agoI used Slug at a previous job. It is an excellent, artfully crafted library; really the pinnacle of software engineering in my opinion. Thanks to the author for donating the algorithm to the public domain!
- adamrezich 7mo agoFinally, some good video game development news!
- Validark 7mo agoAwesome algorithm and thank you for donating it to open source!
- fasterik 7mo ago[flagged]
- Iamkkdasari74 7mo ago[flagged]
- myylogic 7mo ago[dead]
- amagitakayosi 7mo agoAmazing, Thank you Eric!! Also, Microsoft's Loop-Blinn patent for cubic curves will expire on March 25. These might change the landscape of text rendering...
- cylemons 7mo agoI thought loop-blinn expired a while ago, or is the cubic curves separate from quadratic?
- amagitakayosi 7mo agoIIRC their patent is mainly for cubic curve filling. It's still in effect: https://patents.google.com/patent/US7564459B2/en https://patents.google.com/patent/US7564459B2/en
- cylemons 7mo agoAha I saw the paper was published in 2005 and assumed they got the patent at the same time. If they were granted it in 2009 doesn't that means it expires in 2029?
- wei03288 7mo ago[flagged]
- elengyel 7mo agoGlyph complexity has no effect on the calculations done in the pixel shader and does not change how glyphs are preprocessed. There are no edge cases. If you'd like to see some ridiculously complex fonts get rendered with Slug, check out the 8th page in the demo at sluglibrary.com. Some of those individual glyphs are composed of over 1000 Bézier curves!
- rhaen 7mo agoPlease don’t post AI generated comments, it’s against the rules and also just a waste of people’s time.
- andai 7mo agoThis is super cool. A few years ago I was wondering if Ruffle could do something similar, incorporate some kind of GPU accelerated vector graphics. At the time they were going with, approximating the curves out of triangles. I don't know if they're still doing that though.
- tokyovigilante 7mo agoThanks Eric, much appreciated. How would you compare your approach to something like Vello (https://github.com/linebender/vello https://github.com/linebender/vello)?
- elengyel 7mo agoVello is intended more for general vector graphics and would probably perform better with pictures containing lots of large paths. Slug is designed specifically for rendering glyph-like objects and would perform better with lots of text and icons.
- Ono-Sendai 7mo agoI was going to ask if Slug can be used as a general vector renderer. Or does it assume limits on e.g. number of curves/paths per area that are typical of fonts?
- kevthecoder 7mo agoEric answered a similar question on the Discord channel saying Slug is suitable for generic vector graphics. He recommends checking out the demo at https://sluglibrary.com/ https://sluglibrary.com/ (you can cycle through the examples with the space bar).
- Ono-Sendai 7mo agoAwesome, thanks.
- Lichtso 7mo agoI think it is limited to integral quadratic bezier curves, which is sufficient for text rendering. But general purpose vector graphics almost certainly want rational cubic bezier curves too.
- elengyel 7mo ago
- seawsurf 7mo agoSo nice to see this here. The author's books are awesome resources for graphics and C++. It's a shame there seem to be fewer print editions available these days!?
- sbinnee 7mo agoI am not at all familiar with game development. This article reminds me of Casey Muratori mentioning a font issue in game development environment from a random podcast. On web, you can just fetch a google font whatever. No problem. On a local machine, you tend to look a well-established software like harfbuzz. But then harfbuzz could be rather a big dependency. A game is self-contained and you want your font looks cool and unique to your game, like the Diablo font. So it becomes a design issue. It's an awesome approach to let GPU render fonts. I cannot imagine how many game devs had font issues where they realized that they might have to learn how to render fonts as well not just characters and grass.
- flohofwoe 7mo ago> well-established software like harfbuzz Harfbuzz is only one piece of the puzzle, it's not a text renderer, only a 'text shaper' (e.g. translating a sequence of UNICODE codepoints into a sequence of glyphs). The actual font handling and text rendering still needs to be done by some other code (e.g. the readme in Mikko Mononen's Skribidi project gives a good overview about what's needed besides the actual rendering engine: https://github.com/memononen/Skribidi/ https://github.com/memononen/Skribidi/)
- deleted 7mo ago[deleted]
- nickitolas 7mo agoHarfbuzz does shaping, my understanding is slug does rendering. So they do different things
- valentinomici51 7mo ago[dead]
- amelius 7mo ago> I was granted a patent for the Slug algorithm in 2019, and I legally have exclusive rights to it until the year 2038. But I think that’s too long. This is cool but I did not know software patents were still a thing in the US.
- Lichtso 7mo agoThere are two ways to get winding numbers and then decide on filled or empty by some rule like non-zero or even-odd: a) The winding number of a point is the number of intersections of a scanline and a closed path. b) The winding number around a point is the total angle subtended by the path at that point. Slug uses approach a) and that comes with a lot of edge cases (see chart in the post) and numerical precision issues. The approach by loop & blinn uses b) and is thus simpler and more robust. Likewise the patent on that one expired too: https://news.ycombinator.com/item?id=47416736#47420450 https://news.ycombinator.com/item?id=47416736#47420450
- jeremiahkellick 7mo agoLoop and blinn does not compute a winding number using the b) method. It avoids the issue of a winding number by assuming there's only 1 bezier curve per triangle, which requires a complicated triangulation step. It can produce some nasty geometry in more complex cases. With Slug, you can use only 1 quad per glyph if you want. Also just to clarify regarding this statement: > Slug uses approach a) and that comes with a lot of edge cases (see chart in the post) and numerical precision issues Slug does not have numerical precision issues. It's the breakdown into different cases that _solves_ those issues, whereas your statement makes it sound like slug has _both_ the case complexity and the precision issues.
- Lichtso 7mo ago> It avoids the issue of a winding number by assuming there's only 1 bezier curve per triangle The original paper did assume no overlap yes. But that is not how anybody would implement it. For a long time one would use the stencil buffer with different operations depending on the front-face / back-face (this is where the paths rotation around the sample comes in and what makes this an angle based approach). > which requires a complicated triangulation step. It can produce some nasty geometry in more complex cases. Again, not how anybody would implement this. You can just stream the quadratic bezier curves unprocessed into the vertex shader, literally the simplest thing conceivable. > With Slug, you can use only 1 quad per glyph if you want. Nowadays one would probably implement loop & blinn in a tiled compute shader too (instead of using stencil buffers) to reduce memory bandwidth and over draw. That way you also get one quad per glaph, but without any of the geometry special casing that Slug does. > It's the breakdown into different cases that _solves_ those issues, whereas your statement makes it sound like slug has _both_ the case complexity and the precision issues. Correct, might have worded that badly. Still remains a trade off in a) which b) does not have.
- Benjamin_Dobell 7mo agoThanks, Eric; for this, and for my start as a software engineer — my first commercial development work was consulting as an 18 year old building games with C4. I'm really glad Slug was able to find commercial success for you in the way that C4 unfortunately wasn't able to. For those of you who aren't familiar with Eric's work, he's basically the Fabrice Bellard of computer graphics.
- elengyel 7mo agoThanks -- nice to hear from you!
- Ono-Sendai 7mo agoSo now the algorithm is patent-free, and the vertex and fragment shaders are open-sourced with the MIT license, what we presumably need is some open-source code to take Bezier curves from a font file (or from the loaded data from FreeType or whatever), and process them into the data format that Slug expects. Also thank you to Eric Lengyel, I have had my eye on Slug for a while and wished it was open-source.