Freetype -> OpenGL - how? And what about postprocessing?

Discuss technical features of Limit Theory and the LT Engine

Freetype -> OpenGL - how? And what about postprocessing?

Postby axefrog » Fri Jan 23, 2015 9:15 pm

This is another question probably best answered by Josh, but I'm interested in anybody's input if they have done this kind of thing before and understand the pros and cons of different methods.

Seeing as Freetype (I think?), given an input font, style options and a string of text, provides a set of vector outputs for you to do with as you will, I'm wondering what the story looks like in LT regarding the final output as glowy text on screen.

#1. Are the output vectors being translated into a 2D set of triangles and loaded into OpenGL and rendered with a single colour? Or do they get rendered to a texture first using the CPU? (Or the GPU?), with the resultant texture being loaded into OpenGL to be rendered onto a quad?

#2. And once that happens, where does that nice glow come from? Is everything being rendered by the GPU to a texture on the GPU, then having that texture rendered back onto the final scene, with a shader applying the glow to that texture?

#3. The nice grainy effect, along with the analog signal noise degradation that is applied periodically, is that just something applied to the whole scene after the fact? If so, I'm guessing this means that the whole scene is rendered to a texture so it can be post-processed and rendered out to the backbuffer as a texture on a quad?

Very curious about all of this, given that it's an area I've started learning. He who asks questions learns faster :)
I'm learning game programming and blogging about my progress: http://nathanridley.com
User avatar
axefrog
Ensign
 
Posts: 35
Joined: Thu Oct 09, 2014 12:55 am

Re: Freetype -> OpenGL - how? And what about postprocessing?

Postby codeape » Mon Jan 26, 2015 1:47 am

He uses SDF. There is Josh dev blog post about it here: "Implemented kerning caching in SDF font engine" :

SDF and more here: viewtopic.php?f=6&t=2137
Image
User avatar
codeape
Commander
 
Posts: 282
Joined: Mon Jan 07, 2013 2:18 am
Location: Sweden

Re: Freetype -> OpenGL - how? And what about postprocessing?

Postby axefrog » Tue Jan 27, 2015 1:44 am

Thanks, that answers question #1 nicely.
I'm learning game programming and blogging about my progress: http://nathanridley.com
User avatar
axefrog
Ensign
 
Posts: 35
Joined: Thu Oct 09, 2014 12:55 am

Re: Freetype -> OpenGL - how? And what about postprocessing?

Postby JoshParnell » Tue Jan 27, 2015 2:15 am

axefrog wrote:#1. Are the output vectors being translated into a 2D set of triangles and loaded into OpenGL and rendered with a single colour? Or do they get rendered to a texture first using the CPU? (Or the GPU?), with the resultant texture being loaded into OpenGL to be rendered onto a quad?

#2. And once that happens, where does that nice glow come from? Is everything being rendered by the GPU to a texture on the GPU, then having that texture rendered back onto the final scene, with a shader applying the glow to that texture?

#3. The nice grainy effect, along with the analog signal noise degradation that is applied periodically, is that just something applied to the whole scene after the fact? If so, I'm guessing this means that the whole scene is rendered to a texture so it can be post-processed and rendered out to the backbuffer as a texture on a quad?

Very curious about all of this, given that it's an area I've started learning. He who asks questions learns faster :)


Needed a break from code so...I'll answer a question about code instead :roll: :monkey:

1. FT outputs a bitmap (grayscale or monochrome), not vectors. Typically you then take that bitmap and copy it into one or more 'atlas' textures that live on the GPU. An 'atlas' just means you are putting many glyphs on the same texture (much more efficient than having a different, small texture for each glyph). In the case of LT engine I first compute a distance field, so the atlas is the glyph distance fields, not just the glyphs.

2. In the special case of rendering distance fields, we can get a really nice glow for free. For a distance field, 'glow' just means take your favorite falloff function and apply it to the field, e.g. exp(-distance). All of the UI elements are rendered as distance fields, so the UI glow is all computed in this manner (in the pixel shader). The 3D world render, on the other hand, uses traditional post-processing for glow.

3. Yes, this is a post-effect applied to the UI layer. What you see on-screen is the compositing of any number of UI layers, each of which is rendered to a texture and has post-effects applied before finally being composited onto the backbuffer. In the game, for example, there is one layer for the 3D rendered world and one layer for the UI.
“Whether you think you can, or you think you can't--you're right.” ~ Henry Ford
User avatar
JoshParnell
Developer
 
Posts: 4237
Joined: Sun Oct 07, 2012 3:06 pm
Location: Baton Rouge, LA

Re: Freetype -> OpenGL - how? And what about postprocessing?

Postby axefrog » Tue Jan 27, 2015 4:31 am

Thanks for replying, Josh! As always, very helpful :)

Part of this whole journey, for me at least, is building a map of known unknowns that I can use to direct my efforts so that I don't waste time chasing wild geese. Getting some insight from those who have gone before me is very helpful. Thanks again.
I'm learning game programming and blogging about my progress: http://nathanridley.com
User avatar
axefrog
Ensign
 
Posts: 35
Joined: Thu Oct 09, 2014 12:55 am


Return to Technical



Who is online

Users browsing this forum: No registered users and 3 guests