Saturday, March 02, 2019

Text


So, more fooling around on things which aren't what I was going to fool around with. I need text for debugging, among other things, so I decided I would "get that out of the way." Turns out, it's a little bit more complicated than that.

But, after some work, I have it more-or-less working. Well, a start of it. One part was just getting characters rendered onto textures. Then, of course, I had to start working on distance fields, because all the kids are talking about distance fields these days. The screen shot below might illustrate why.


The two words are rendered using textures of the same size (about 32 pixels high in total). The top one is anti-aliased text, and the bottom is a distance field. The distance field is generated from anti-aliased text at four times the resolution, and then scaled down. As you can probably see, this produces a nice clear shape even at the relatively low resolution of the final texture. Generating distance fields from anti-aliased text, caching font info, getting text and distance fields added to my material definition formats, that all took a bunch of time.

And I still have to get this text stuff into the UI.