A GPU Based Font System

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

A GPU Based Font System

Post by Assaf Raman »

Has anyone implemented this nice article?
http://alice.loria.fr/publications/pape ... TM/vtm.pdf

Here are the screenshots of the article:
Image
Image
Image
Image
Last edited by Assaf Raman on Sun Jan 06, 2008 11:33 am, edited 1 time in total.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

this is also in the same area - also with source!
Beyond the pixel: towards infinite resolution textures.
pdf: http://staffwww.itn.liu.se/~stegu/GLSL- ... conics.pdf
source + EXE: http://staffwww.itn.liu.se/~stegu/GLSL- ... conics.zip

If you are using visual studio 2005 - I made a vc2005 version of the code, just download and compile: http://assaframan.googlepages.com/GLSL-conics-vc8.zip
Watch out for my OGRE related tweets here.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

I don't have the time to play with it right now, but that's seriously cool.
broli
Halfling
Posts: 48
Joined: Fri Mar 31, 2006 5:08 pm

Post by broli »

That's indeed mighty intresting and doesn't look to difficult to implement, there are so many posibilities with this and the framerates are astronomical . (it's bugged for ATI though) :shock:

Thinking about it now this might be a cool addition to ogreSwf to have true vectorised textures ;)
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

One more nice article on this subject:
http://www.cgl.uwaterloo.ca/Projects/re ... exture.pdf

Here are the screenshots of the article:
Image
Image
Image
Image Image
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

One more nice article on this subject:
http://research.microsoft.com/~cloop/loopblinn05.pdf

Here are the screenshots of the article:
Image
Image
Image
Watch out for my OGRE related tweets here.
kuxv
Google Summer of Code Student
Google Summer of Code Student
Posts: 53
Joined: Wed Jan 09, 2008 7:51 pm
Location: Czech Republic
x 16

Post by kuxv »

Hi,
i wonder if anybody has already implemented this feature. I'm currently looking for a topic for my master's degree and this looks interesting to me. If it's still not implemented i'd be happy to do it if i find any teacher who will approve it. I'm not pretty sure about it's complexity and suitability for such a work so I'll have to ask first.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

They showed the Microsoft one at GameFest last year -- it was truly cool.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

You can see in the thread I found an implementation of something with source in the same dial area – but not the font system.
Only last Sunday I sat and reread the articles, I guess they are too complex for me to implement in my spear time.

If you will implement it – I promise you the whole community will thank you – as this issue is in the OGRE “help neededâ€
Watch out for my OGRE related tweets here.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

It wouldn't be strictly limited to fonts -- vector graphics rendering in general would all work the same way, so a more general solution would be desired (and take much longer as a result).
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

xavier wrote:It wouldn't be strictly limited to fonts -- vector graphics rendering in general would all work the same way, so a more general solution would be desired (and take much longer as a result).
I agree, but also a GPU based font system will be nice.
If we have that - from it to full SVG support - not that hard.
Watch out for my OGRE related tweets here.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

Actually it is, somewhat.

In terms of Ogre, and how it is designed, it is far more important to consider the font issue in the context of a broader vector graphics framework, rather than try to do this focused little bit now and try to expand it later. The guy who thought he had the "OpenGL 3" issue licked because he hacked in support for the geometry shaders extensions, found that out. Just hacking in support for TrueType/OpenType fonts, isn't really a worthwhile thing to do.

No one is starving right now because there isn't a vector font solution in Ogre. It's worth the extra time to do it right.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
kuxv
Google Summer of Code Student
Google Summer of Code Student
Posts: 53
Joined: Wed Jan 09, 2008 7:51 pm
Location: Czech Republic
x 16

Post by kuxv »

Ok, i accept all advices you can give me. But i don't know if i have enough time to make it. I don't know how difficult it will be to implement whole vector graphics framework. I have experience with computer graphics but i don't have any experience with Orge. I think it will be easy to learn but I can't tell that for sure. Do you think that 3 months will be enough time to make whole vector graphics framework for Ogre ?

P.S.: Don't take me wrong, I'm not doing it just because I need some work for school. I would learn a lot by this and I wanted to do something usefull long time ago but haven't kicked myself to it :(
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Post by Klaim »

If you have experience with 3D api programming (with DX or OpenGl ) then i don't think Ogre will be a problem. I'm not a specialist here (lack of experience in advanced 3D programming) but it seem that the main difficulty in this feature is that it require a lot of knowledge about svg data, curve manipulation, and shaders.

Anyway you should just start and maybe you'll do something useful enough to let experienced people here "polish".
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

kuxv wrote:Ok, i accept all advices you can give me. But i don't know if i have enough time to make it. I don't know how difficult it will be to implement whole vector graphics framework. I have experience with computer graphics but i don't have any experience with Orge. I think it will be easy to learn but I can't tell that for sure. Do you think that 3 months will be enough time to make whole vector graphics framework for Ogre ?

P.S.: Don't take me wrong, I'm not doing it just because I need some work for school. I would learn a lot by this and I wanted to do something usefull long time ago but haven't kicked myself to it :(
It would take discussion with Sinbad about how it might work within the context of Ogre. The reason is that the common way of doing this is (a) generate the meshes offline and render them using pixel shaders with the relevant textures, or (b) do the mesh generation at runtime, which is more flexible but potentially slower. The data path is largely the same.

You could theoretically do this as a plugin or addon as well. The issues either way is mainly integration with the Ogre font rendering system, in terms of fonts. Font glyph and texture generation would more or less be overridden with this system.

It's an interesting project, for sure. Only Sinbad can say where it would best live within Ogre.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

Implementing any of the articles to a demo – will be a step forward. All the articles describe architecture to draw paths with shaders and the font system is always the extension. So – that is why a font system if good for me – it is more then your offer xavier.
Watch out for my OGRE related tweets here.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

LOL I don't think I offered to do this -- it's of no use to me, to be honest. I was just pointing out that I saw the presentation you linked to at Microsoft. ;) It was cool, but nothing to make me stop everything I am doing to do this.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16
Contact:

Post by KungFooMasta »

Xavier, keep us updated with your results! :lol:
Creator of QuickGUI!
User avatar
cybereality
Hobgoblin
Posts: 563
Joined: Wed Jul 12, 2006 5:40 pm
x 12

Post by cybereality »

That would be a cool feature if available as a plug-in.

I wonder if a generalized method of this would be useful in creating a full 3d vector render system within ogre. Meaning both vector textures and vector geometry (ie NURBS). Obvious benefits would be real curved surfaces, unlimited mesh density and thus advanced LOD options (since all polys would be generated on the fly). I am assuming this would be possible with dx10 geometry shaders, no?
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

cybereality wrote:I am assuming this would be possible with dx10 geometry shaders, no?
geometry shaders don't solve it as good.
geometry shaders will create a large amount of triangles for the curves, the aritcles talk about a way to draw the curves in the shader - so less geometry and infinite resolution.

You can do the same as the geometry shaders on the CPU - like the "polygon font sample" I posted does:
http://www.ogre3d.org/phpBB2/viewtopic. ... sc&start=0

In the geometry shader you will need to do triangulation.
Here are some links I found about triangulation in geometry shaders:
http://www.tech-archive.net/Archive/Dev ... 00009.html
http://www.icare3d.org/content/view/50/9/

I guess that all the articles have code that creates geometry, so if you create that geometry in a geometry shader – it can be nice.

OGRE doesn’t support geometry shaders yet.
Watch out for my OGRE related tweets here.
Silicon Savvy
Gnoblar
Posts: 8
Joined: Thu Aug 21, 2008 3:00 am

Post by Silicon Savvy »

Hello Ogre community!

Assaf, thank you very much for collecting all of the wonderful articles.
I've decided I'm going to tackle this project in my spare time. After about a week I currently have a tiny program which spits out a curvy outline of a truetype glyph. I wanted to make sure I could at least get that far before I announced my involvement.

The first and most obvious question I have is if anyone else is already working on this.?

If nobody else is doing this, I'll probably start another thread for keeping track of my particular implementation for this problem. However, I'd like to make a few observations and pose a few questions about how this technology should be integrated into OGRE.

1. I know there's been talk about different methods of accessing really high resolution textures. Do they make this obsolete (yet)?

2. I'm implementing Loop & Blinn's method; it seems to me that they've put the most thought into designing a technique that's actually practical to use.

3. I'm using true-type fonts (currently). The technique will easily work with any font file format / api combo that will split some shape into quadratic bezier curves and straight lines. xavier, you've made your feelings on this clear, but I see TrueType as a mature 2d vector graphic format that already has content creation tools available for it.

I have put a lot of thoughts into this but I'll summarize them for now by saying that what I'm trying to accomplish is 2d fonts being displayed at any distance / orientation in ogre. There's a lot more things that could be accomplished with this or similair technology but there's always a better technique around the corner, not to mention hardware will continually improve the old techniques.

What I'm saying here is that if we try to account for every possible application of this we will spend more and more time developing for a smaller and smaller audience, all the while hardware is getting better and marginalizing the improvement of this versus bigger textures. Also, OpenVG is a more open-ended bullet on the wish list that I don't want to overlap. Furthermore, remember that just because it's meant for fonts, doesn't mean anything should keep content creators from making new abstract glyphs a la "WingDings."

4. Pt 4 was an overly long explanation of why I'm not trying to replace Ogre's built-in font system with this. These are my main concerns:
-I'm not familiar enough with Ogre's font system to design a replacement for it but:
-Ogre's font system and a GPU font system should not be trying to accomplish the same thing. Ogre's font system is designed to spit out colored 2d-textures which represent a graphical representation of the font (or so it seems to me).
GPU based font systems are designed to spit out abstract sets of data which is used to cleverly render shapes across a fragment. I just don't see how code written for the first system would be able to compile and produce the same results with code from the second system. Nor can I think why anyone would want GPU fonts for screen-aligned 2d text, improvements in quality or speed would be minimal if existent. Of course, I'd love to prove myself wrong on this.

5. This is how I imagine the system being used in practice:
-The content creation tool calls the new GPU font system to generate a mesh that contains a glyph or a string.
-The artist adds this mesh to their model as a subentity (or whatever the terminology is for this scenario).
-The end user's application needs no additional code to render the mesh. The submesh (or the right term for what I'm describing) is associated with a material which has the GPU renderer as a technique.

p.s. Sorry for the very verbose post. Also, I'm admittedly new to pretty much everything I'm trying to do here, OGRE included, so please cut me some slack if I've grossly misused some terminology. Or if I'm way off on some aspect of this concept altogether, please just shake your head and try to correct me. :P
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

Silicon Savvy wrote:xavier, you've made your feelings on this clear, but I see TrueType as a mature 2d vector graphic format that already has content creation tools available for it.
I don't recall saying anything about TrueType/OpenType per se. If you re-read what I said, it was the notion of hacking in a quick solution (rather than working within the framework to make it integrate properly), that I disagreed with.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
Silicon Savvy
Gnoblar
Posts: 8
Joined: Thu Aug 21, 2008 3:00 am

Post by Silicon Savvy »

Thanks for clearing that up xavier, sorry I misunderstood and misrepresented you. I agree wholeheartedly that how the project is integrated into ogre needs to be considered from the beginning as well as how it might integrate with other advanced tech. I believe how it should integrate will depend on how it's going to be used.

I think what I envisioned as the usage earlier is nicely open-ended. For instance, the new LOD system could be made to ask the GPU font sys to generate meshes in near realtime for a high LOD. Of course an application could also add more passes to the material associated with the mesh to add more realism to the image the font system would produce.

Can anyone think (or has anyone thought) of a better way this project could be used in practice?
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Post by Klaim »

Can anyone think (or has anyone thought) of a better way this project could be used in practice?
I'm building an interface system for my game that is made of 3D flat shapes (like quads, but not necesarly squared) moving in 3D space. Displaying text in 3D is a big problem i have currently because there is no easy way to do this efficiently. So this could be interesting in my case. For instance i'm finishing the movement systems and was thinking of trying different techniques for different type of texts.

The bigger problem i have is that the displayed 3D texts in my console interface require the text to be modified very quickly in real time and very often. My current implementation is a basic rewriting + blitting of a texture with the text of my console. I will soon need a better solution to display 3D text very fast and i collected some techniques (all based on some texture and/or shader) i need to try when the it will be time to work on this point.
So, i think GPU Font may help me render 3D text nicer than with textures, but i'm not sure it will resolve the console case.

The other requirement for all my interface system is that the elements of the interface have to be easily graphically modified, so flexibility is a big concern in my project.

Anyway, if you make this system, i'll use it :) (at least for some "static" texts i want to display and move through space). I wanted to try to do it myself but i lack time. :?

I'm not sure i understand clearly you point 5. Do you mean the text HAVE to be created before compile time? Couldn't the mesh generation be done on demand in runtime?
Silicon Savvy
Gnoblar
Posts: 8
Joined: Thu Aug 21, 2008 3:00 am

Post by Silicon Savvy »

3D flat shapes (like quads, but not necesarly squared) moving in 3D space
That's it exactly! If all you need is disembodied text, then you could easily use the GPU font system directly in your app.

See Assaf Raman's polygon font demo + 3d text demo, http://www.ogre3d.org/phpBB2/viewtopic. ... highlight=. The example of generated polygons (not meshes) that he creates are very similar to what would be created by this method.

To understand pt 5 better, read the last paragraph of section 7 of Loop & Blinn's article http://research.microsoft.com/~cloop/loopblinn05.pdf, which talks about taking these plane aligned meshes and projecting them onto existing meshes. This is the part that I imagine being done in a content creator, partly because its not work that I'm willing to do for this yet. Sorry I wasn't more clear about that.

As for whether or not the mesh can be generated in realtime, you'd likely end up with one mesh representing a block of text that was made up of submeshes representing each glyph. Changing text around just means changing the parent mesh and I'd think that most definitely, this is something that will be done in realtime without a fuss.

As for the generation of the actual glyph meshes, they're pretty trivial and could probably be generated before each one was used. However, 99.9% of the time you just want the GPU font system to generate these in advance for you, when you select the font you want to use would be a good time for this to happen.
A Glyph mesh in this system would likely take up less space than it's TrueType equivalent, so we can easily speed this up even more by caching a particular font's meshes on the disk.

I love the 3d console idea and I think this system is definitely something you can use for it!
It reminds me of an idea I had for a really perverse demo: you walk up to a computer in the middle of a 3d scene. You could then edit and recompile the shader code used by that scene to change it in real time. Don't mistype, or it's lights out! :P

Seriously, it's awesome to hear that you would have a use for this, Klaim. That's enough for me to justify really going forward with this. More to come.
Aliens made me smart. They also made me a little bit crazy; this was done for obvious reasons.
Post Reply