Hi, I'm in need to be able to convert a font that I generated with BMFont to SDF format, I tried to achieve the same look as SDF with editing the texture in photoshop, but the look was not what I was after…
so I wonder there is any good way for doing it? thanks.
There is anyway to convert BMFont output font to sdf format?
YouKnow said:
I tried to achieve the same look as SDF with editing the texture in photoshop, but the look was not what I was after…
This would work well only if you had the font bitmaps at higher resolution (like 4 times or more), then downscale the final result. Worth a try.
Otherwise it's hardly possible, because alpha pixels are not enough to specify the boundary where the distance should be zero but respecting the original shapes. Some fancy filters would help, but not worth the effort i think.
I was looking for SDF alternatives to BMFont years ago, but did not really find anything great. Probably this has changed meanwhile.
Would be really nice if they added SDF to BMFont directly.
JoeJ said:
This would work well only if you had the font bitmaps at higher resolution (like 4 times or more), then downscale the final result. Worth a try.
Otherwise it's hardly possible, because alpha pixels are not enough to specify the boundary where the distance should be zero but respecting the original shapes. Some fancy filters would help, but not worth the effort i think.I was looking for SDF alternatives to BMFont years ago, but did not really find anything great. Probably this has changed meanwhile.
Would be really nice if they added SDF to BMFont directly.
thank you for answer, so you saying for example first create a texture with size of 4096x2048 and font size of 160 for example, then down scale it to 2048x1024 | 80 and use it? (this way I need to edit the font data too) yeah I think I can do that, but I'm not sure if the end result come up good…
yeah they said the SDF is a Work in Progress thing for later version of the tool…
but I'm not sure if we ever going to see it…
4096x2048 and font size of 160 for example, then down scale it to 2048x1024 | 80 and use it?
I think that's not enough. I meant resolution x 4, not area. So you would need 8192 x 4096, if 4 x is enough. Not sure, as Photoshop tends to generate jaggy gradients with the precise setting.
The font data could be divided by 4 on import to keep it simple.
In case results are still bad, it's probably a Photoshop issue, and you need to convert yourself.
I work a lot with density and SDF volumes currently, but converting density to SDF is not trivial.
What i do is like this:
Density has values between 0 and 1. I convert them to initial distance with: distance = (density-0.5) * 2;
After that i use the ‘Jump Flood Algorithm’ for an intial guess for the whole data, which ends up noisy.
To smooth it out, i use iterations of some gradient descent solve.
Probably too much effort just to get better font rendering, so i would search for alternative tools or libraries first.
@JoeJ thanks for answers, yes it going to take some times to get it right… but sadly I don't know any alternative tool that capable of generating any SDF fonts…
YouKnow said:
Hi, I'm in need to be able to convert a font that I generated with BMFont to SDF format, I tried to achieve the same look as SDF with editing the texture in photoshop, but the look was not what I was after… so I wonder there is any good way for doing it? thanks.
Try these links that I share on the BMFont page:
- http://bitsquid.blogspot.com/2010/04/distance-field-based-rendering-of.html
- https://www.gamedev.net/topic/491938-signed-distance-bitmap-font-tool/
YouKnow said:
yeah they said the SDF is a Work in Progress thing for later version of the tool…
but I'm not sure if we ever going to see it…
“They” being me ?
It is true that I don't spend time on enhancing BMFont anymore. Nowadays I concentrate pretty much all of the time I have left for my projects on AngelScript.
But if someone were to implement the support for SDF in BMFont and contribute the share the source code I'd be happy to merge it into the tool.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
I forgot to mention we can also calculate an approximate SDF as an exponential sum of density mipmaps.
For fonts we need accuracy only at the boundary, so this should be good enough i think. And this could be implemented in the rendering pixel shader, sampling just two LODs of texture.
But at this point i'm not really sure if the claims of SDF giving better quality are actually true.
It could be just more sharpness, but at the cost of higher aliasing. That's how it looks to me.
WitchLord said:
Try these links that I share on the BMFont page:
- http://bitsquid.blogspot.com/2010/04/distance-field-based-rendering-of.html
- https://www.gamedev.net/topic/491938-signed-distance-bitmap-font-tool/
“They” being me ?
It is true that I don't spend time on enhancing BMFont anymore. Nowadays I concentrate pretty much all of the time I have left for my projects on AngelScript.
But if someone were to implement the support for SDF in BMFont and contribute the share the source code I'd be happy to merge it into the tool.
Oh ?
first of all, thank you for your tool, I cant count how many times I used it… its helped me a lot…
looks like download links in the first link that you sent to me are dead… (At least I can't download them)
links in second link are look dead too…
I sadly don't know much about C++, so cant contribute to the project… but it would be very good if we can have an option for generating SDF font in the tool in future…
again thanks for your works.
JoeJ said:
I forgot to mention we can also calculate an approximate SDF as an exponential sum of density mipmaps.
For fonts we need accuracy only at the boundary, so this should be good enough i think. And this could be implemented in the rendering pixel shader, sampling just two LODs of texture.But at this point i'm not really sure if the claims of SDF giving better quality are actually true.
It could be just more sharpness, but at the cost of higher aliasing. That's how it looks to me.
thank you for answer and help, tbh using SDF actually do help to get a better result, yes the edge will become a little round, but at least its look better in higher resolutions…