Live data from Hacker News

Easy Scalable Text Rendering on the GPU

medium.com

31–40 of 42 posts

Re: Easy Scalable Text Rendering on the GPU

#31
post #2

Minus antialiasing, the stencil buffer version of this technique has been described in the Red Book for a long time: http://www.glprogramming.com/red/chapter14.html#name13

Is there any reference to where this technique originated? I think it is much more elegant than the traditional point-in-poly ray-cast rasterization technique.

Re: Easy Scalable Text Rendering on the GPU

#32
post #2

Minus antialiasing, the stencil buffer version of this technique has been described in the Red Book for a long time: http://www.glprogramming.com/red/chapter14.html#name13

Yes, the methods here have been seen before, but there were some tricks that I haven't come across earlier. Avoiding the stencil buffer (why?) with additive blending in color buffer is something I haven't heard of before. Similarly, the implementation details of the antialiasing using color buffer seem like original work to me.

I think that this was partially motivated by limitations in WebGL. More modern graphics APIs would allow better control over the render target (no need to hassle with RGBA8 using arithmetic tricks, just use integers if you need) and multisampling (gl_SampleMask for MSAA'd "discard" of fragments).

I was familiar with the Loop-Blinn stencil-then-cover trick (and I've worked with GPU path rendering before) but there were some interesting tidbits in this article regardless.

Re: Easy Scalable Text Rendering on the GPU

#33
post #2

Minus antialiasing, the stencil buffer version of this technique has been described in the Red Book for a long time: http://www.glprogramming.com/red/chapter14.html#name13

Is there any reference to where this technique originated? I think it is much more elegant than the traditional point-in-poly ray-cast rasterization technique.

> I think it is much more elegant than the traditional point-in-poly ray-cast rasterization technique.

This is pretty similar to the point-in-poly raycasting (this is especially clear if you use the stencil buffer, but for some reason the author actively avoids that). You might also see some similarities with stencil shadow volumes (as seen in Doom 3).

There's two tricks used here: stencil-then-cover for the "bulk" of the shape and the Loop-Blinn method for doing quadratic Bezier curves in a triangle. You can find plenty of resources on both.

Re: Easy Scalable Text Rendering on the GPU

#34
post #3

If you want to read on distance field rendering : http://blog.qt.io/blog/2011/07/15/text-rendering-in-the-qml-... . This is used in QML's text rendering (not Qt widgets though).

The one downside is that you need a 64x64 texture for each glyph, whereas using polygons, you can probably do it in much less memory. As a quick calculation, assuming you're using an 8-bit distance field, memory for one glyph is 6464 bytes, whereas if you store the points as 2D coordinates in float16 precision, it's (16+16)num_points, or one 64x64 texture occupies the same space as 128 points.

Re: Easy Scalable Text Rendering on the GPU

#35
post #32
post #2

Minus antialiasing, the stencil buffer version of this technique has been described in the Red Book for a long time: http://www.glprogramming.com/red/chapter14.html#name13

Yes, the methods here have been seen before, but there were some tricks that I haven't come across earlier. Avoiding the stencil buffer (why?) with additive blending in color buffer is something I haven't heard of before. Similarly, the implementation details of the antialiasing using color buffer seem like original work to me. I think that this was partially motivated by limitations in WebGL. More modern graphics AP…

> Avoiding the stencil buffer (why?)

Maybe there is a software patent he tries to avoid?

Re: Easy Scalable Text Rendering on the GPU

#36
One downside to this vs SDF is that you would have to distribute font with your application. With that you have to license/buy that font properly. With SDF you're creating an image out of which you derive fonts and for that you don't need to license the font for distribution.

Re: Easy Scalable Text Rendering on the GPU

#37
post #32
post #2

Minus antialiasing, the stencil buffer version of this technique has been described in the Red Book for a long time: http://www.glprogramming.com/red/chapter14.html#name13

Yes, the methods here have been seen before, but there were some tricks that I haven't come across earlier. Avoiding the stencil buffer (why?) with additive blending in color buffer is something I haven't heard of before. Similarly, the implementation details of the antialiasing using color buffer seem like original work to me. I think that this was partially motivated by limitations in WebGL. More modern graphics AP…

> Avoiding the stencil buffer (why?)

GPUs and all drivers do not support independent stencil buffer. If you need a stencil buffer, then you need to make a Depth=24, Stencil=8 buffer, also called D24S8.

If you have floating-point 32 bit depth format, sorry, no stencil buffers. If you don’t have depth at all, stencil buffer would take 4 times more VRAM: for color buffer, having just single component is fine, e.g. GL_R8UI or DXGI_FORMAT_R8_UINT.

Re: Easy Scalable Text Rendering on the GPU

#38
post #30

I don't get why zooming up the subpixel antialiased image and looking at the color fringes makes sense [1]. Why would you want to remove color fringes from here? That's not what you see, you see [2]. I don't see color fringes in [2]. [1] https://cdn-images-1.medium.com/max/1400/1*Uqt60m0luG2S8lm3h... [2] https://cdn-images-1.medium.com/max/1400/1*VoJ6TfORiCHAHy3SN...

You can see the color fringe when you view the character without zooming, here is an example I have found:

http://fsrv.dyndns.org/mirrors/dmedia-tutorials-textrenderin...

Make sure the image isn't scaled to see the text as sharp but with color fringe (on the left side of the image).

The image is from this other great article about sub-pixel font rendering: http://fsrv.dyndns.org/mirrors/dmedia-tutorials-textrenderin...

Re: Easy Scalable Text Rendering on the GPU

#39

One downside to this vs SDF is that you would have to distribute font with your application. With that you have to license/buy that font properly. With SDF you're creating an image out of which you derive fonts and for that you don't need to license the font for distribution.

SDFs make my brain happy about the universe. I sense they will only grow in importance.

Re: Easy Scalable Text Rendering on the GPU

#40
post #33

Earlier quoted context omitted.

Is there any reference to where this technique originated? I think it is much more elegant than the traditional point-in-poly ray-cast rasterization technique.

> I think it is much more elegant than the traditional point-in-poly ray-cast rasterization technique. This is pretty similar to the point-in-poly raycasting (this is especially clear if you use the stencil buffer, but for some reason the author actively avoids that). You might also see some similarities with stencil shadow volumes (as seen in Doom 3). There's two tricks used here: stencil-then-cover for the "bulk" o…

Agreed, but my cg education (many moons ago), usually covered point in poly with a specific section of code to do ray intersection with segments. None that I can recall used the stencil trick, which is so much more clever and simple than solving line equations. I am just wondering... who came up with that first?

I looked for the original Warnock paper online, but it is behind the ACM paywall. That would at least tell me if they knew of that in the mid 80's.

I will check out the Doom 3 stuff. I had that on my reading list from a while back.

Thanks for your answer.

Post reply on HN