Live data from Hacker News

Show HN: GPU text rendering with vector textures

wdobbie.com

21–30 of 91 posts

Re: Show HN: GPU text rendering with vector textures

#21
post #17
post #7

See also: http://www.msr-waypoint.net/en-us/um/people/cloop/LoopBlinn0... (work done on the subject at Microsoft Research, with more of the math described).

You might not want to read that, afaik that technique is patented. :)

Well now that you said that it's 3x damages, whether or not you read it (at least in the US, the standard is whether there's "an objectively high likelihood" of infringing some patent that is "either known or so obvious that it should have been known" to you, so knowing that a thing's been patented counts even if you don't read the patent).

But even 1x damages are pretty high. Read it carefully and do something sufficiently different and avoid infringement in the first place.

Re: Show HN: GPU text rendering with vector textures

#22
Signed Distance Field fonts are wonderful! I've been using a Unity extension called TextMesh Pro, which works very efficiently, and renders beautiful text that you can configure and decorate in many ways.

Beyond the obvious benefits of SDF fonts, it also has excellent and extensive layout, formatting and other useful features, like automatically scaling the text to fit in a given area.

The source code for the shaders and formatter and ugui integration is included, but not the atlas generator (although you might ask the developer if you need it -- he's engaged and helpful, and provides good support and quick fixes for Unity updates). It includes desktop shaders with many fancy features (outlines, drop shadows, beveling, glow, bump mapping, a surface shader that reacts to lighting and throws shadows into the world), and simplified optimized shaders for mobile.

I've used it (and read the source code to see how it works), and can testify that it works great on Unity's desktop, iOS, Android and WebGL backends. The code itself and the way it offloads so much work to the GPU is very beautiful and elegant.

TextMesh Pro - Unite 14 Demo: https://www.youtube.com/watch?v=q3ROZmdu65o

Here's a benchmark that compares 5000 crisp TextMesh Pro objects rendering at 70 FPS, versus 5000 fuzzy Unity text objects rendering at 42 FPS: https://www.youtube.com/watch?v=rdc8UkxuSZc

Here's the same benchmark compiled with Unity's WebGL backend, with the same number of 2500 static and 2500 dynamic text objects. Nowhere near the 70 FPS of native code of course, but not bad for WebGL and so many objects -- zoom in with the mouse wheel to see the text up close: http://donhopkins.com/home/TextMeshProBenchmark/

TextMesh Pro on the Unity Asset Store: https://www.assetstore.unity3d.com/en/#!/content/17662

Digital Native Studios home page: http://digitalnativestudios.com/

Re: Show HN: GPU text rendering with vector textures

#24
post #2

Exactly what I needed, just as I was about to start screwing with distance fields or the like. THANK-YOU! Edit: I may have spoken slightly too soon, not since the technique isn't awesome, but because this isn't yet usable without an atlas generation tool that I don't know how to build. As far as performance goes, this is rendering a 124-page PDF (I know, just the glyphs...) utterly without lag using the GPU, on a 16…

TextMesh Pro comes with an atlas generation tool. See my description above.

Re: Show HN: GPU text rendering with vector textures

#26
post #3

Very clever technique! It seems more true to letterforms than SDF. Seems like it might need more texture bandwidth/dependent reads than SDF, but less texture memory as a whole? I've been looking at different text rendering methods for a VR engine. I wonder if this technique works in 3D space? If so I'll give it a shot, benchmark it against SDF :)

I'm using TextMesh Pro for a VR/AR application in Unity called Pantomime, and it works great for text in the 3d world space, as well as 2d gui dialogs. You can get up really close to the text, and it looks perfect. I posted some links to demos on the TextMesh Pro forum here:

http://digitalnativestudios.com/forum/index.php?topic=470.ms...

Some discussion about text in VR:

https://www.reddit.com/r/oculusdev/comments/34d8nm/reading_i...

More about Pantomime:

http://pantomimecorp.com

Re: Show HN: GPU text rendering with vector textures

#27
This is really neat. Though in practice if you are using this kind of thing I'm pretty sure you will want to combine it with atlasing (i.e. construct an atlas of glyphs via render to texture). That's because it's a waste of time to rerasterize glyphs in the FS every frame (which appears to be 200+ lines) instead of caching the results and reducing the per-frame work to a 5-line FS that just blits. In most apps pans are more common than zooms and the same glyphs are used over and over, so this usually ends up being a win. Using atlases also reduces the number of raster operations because the same glyphs tend to appear on the page repeatedly, and by using atlases you rasterize each glyph only once. Even more importantly, though, atlasing gives you the ability to reuse a blitting fragment shader to render other content (images, figures, etc.) as well as glyphs from the atlas in order to reduce state changes.

Re: Show HN: GPU text rendering with vector textures

#28

This is a cool technique. The WebGL demonstration is pretty compelling! It's a little odd to me that they describe distance fields as having an unavoidable problem with sharp corners, though. The Valve paper on signed distance fields for text demonstrates a simple workaround that fixes sharp corners...

While it seems simple in the paper, it is way more complicated to implement in practice as it comes with all sorts of edge cases.

https://lambdacube3d.wordpress.com/2014/11/12/playing-around...

Re: Show HN: GPU text rendering with vector textures

#29
post #5
post #2

Exactly what I needed, just as I was about to start screwing with distance fields or the like. THANK-YOU! Edit: I may have spoken slightly too soon, not since the technique isn't awesome, but because this isn't yet usable without an atlas generation tool that I don't know how to build. As far as performance goes, this is rendering a 124-page PDF (I know, just the glyphs...) utterly without lag using the GPU, on a 16…

It's very laggy and slow on a quad i7 16GB Macbook Pro. Presumably this is because of the retina display.

It's amazingly smooth, I'd say 60+ fps, on my i7-3770K desktop (Geforce GTX970) with Firefox Developer Edition.

Re: Show HN: GPU text rendering with vector textures

#30
Great work! Is there any WebGL source available?

The demo runs very poorly on my 15" MBP (late 2013, Intel Iris Pro). I'm not sure if it's just the sheer number of glyphs being rendered at once, or whether it's something specific that this GPU is having trouble with.

Some related links for those interested in WebGL text rendering:

1 - https://github.com/Jam3/three-bmfont-text

2 - http://mattdesl.svbtle.com/material-design-on-the-gpu

3 - https://github.com/mattdesl/text-modules

Post reply on HN