Integrated Viktor Chlumksy's multichannel signed distance fields library into the engine. Basically, it's a font atlas generator, plus he was kind enough to provide a fragment shader that takes the msdf textures and renders them as text. The advantage of a signed distance fields vs plain bitmaps is that they retain sharpness when zooming in, so you can have varying sizes of text without needing multiple atlases to keep them all crisp. SDFs do have a few visual aberrations, but msdfs basically fix those. There are more advanced font rendering techniques, like the Slug library, but that allegedly costs a lot of money, while MSDFgen is free. It did take some tinkering and adjusting to get the plane and uv coordinates correct, but now it works. Kind of. There are some screenshots attached, with zones assigned a random colour and numbered label for testing purposes.
View attachment 33185View attachment 33186View attachment 33187View attachment 33188
You can see the problems.
1. Line-of-best-fit using tile centres works ok with some shapes, not with others. Sometimes the text isn't centred in the map shape it's supposed to label; sometimes it's partially or even entirely outside the object. Something like Paradox does, where they use a sequence of lines to determine the overall largest curve they can fit inside a polygon, would be better. But some parts of the description I've read (from one of their developers) are a bit unclear in their meaning, perhaps because I'm not a math guy. Of course, there's probably some value adjustments I could do to my label baseline generation function that might help, but at the end of the day the Paradox method is much better.
2. Signed distance fields look great when zoomed in (that is of course the weakness that plain bitmap text faces) but not so great when zoomed out. Fragment shader tuning may help (adjusting a certain value in it shifts between texts looking reddish and occluded, or plain black and transparent but with some loss of shape when zoomed out , and I'll mess around with that more at some point, but there are issues there. Some sort of culling mechanic for very small labels might work (so they just don't show up until zoomed in enough that they'd be readable), but I'm not sure how I'd implement that; perhaps having a bunch of layers for labelling and add labels into them with the selection being based on their overall span, and then exclude small-span layers from the rendering list when zoomed out.
Ultimately, I'm probably going to leave the labels as is for the time being; they aren't good for a release state but they're serviceable enough for development, and I've spent long enough on rendering and want to move to a different part of the program for now; specifically I want to begin filling in the mechanics of pop simulation, starting with basic staffing of agricultural operations. Although before I do that I need to do some research on soil.