overte-org / overte

Overte open source virtual worlds platform.
https://overte.org/
Other
128 stars 47 forks source link

Text Entity Improvements #937

Closed HifiExperiments closed 2 weeks ago

HifiExperiments commented 2 months ago

Closes #583 and #126

incredibly this is NOT a protocol change šŸ˜„

This adds support for smarter text clipping at the edges of text entities, as well as replacing the old text font format with https://github.com/Chlumsky/artery-font-format

New fonts can be created trivially from .ttf and .otf font files using https://github.com/Chlumsky/msdf-atlas-gen/ (windows download available: https://github.com/Chlumsky/msdf-atlas-gen/releases). Eventually it would maybe be nice if we packaged the generator with our releases.

Here's the command I used to generate the default fonts (you must use mtsdf as the type): msdf-atlas-gen.exe -font Roboto-Regular.ttf -type mtsdf -fontname Roboto -format png -arfont Roboto.arfont

I think there's still some room to improve the antialiasing and other effects since right now we use a hard cutoff for the opacity, which somewhat defeats the purpose of sdfs, but that's a bit more complicated so I left it for a follow up.

Funding

This project is funded through NGI0 Entrust, a fund established by NLnet with financial support from the European Commission's Next Generation Internet program. Learn more at the NLnet project page.

NLnet foundation logo NGI Zero Logo

vegaslon commented 2 months ago

This text entity is not rendering correctly anymore in the tutorial https://i.gyazo.com/1118d6635fa19506c425912a96a1d927.jpg

SilverfishVR commented 2 months ago

Yea, the portal text entity needs to be a tiny bit wider.

But finally, we can add fonts yay!šŸŽ† šŸŽ‰ Screenshot 2024-04-19 00 32 17 It takes some fiddling with the settings to make it look nice, the default size is way too crusty looking and the 7-segment font still has a start offset that I can't figure out how to fix.

also, only png format works, so that should be noted in documentation too.

HifiExperiments commented 2 months ago

the text is supposed to no longer completely disappear when it reaches the edge of the entity, so it sounds like there is a bug there. I will look into that.

bmp format is also supposed to work, I will test it again

could you share the font that has the problematic start offset?

SilverfishVR commented 2 months ago

bmp does not generate at all so I did not test: Atlas type not compatible with image format. MTSDF requires a format with alpha channel. png is probably preferred anyway so not really an issue.

As for the offset issue, I am an idiot šŸ¤¦ It is a fixed width font (as it should be) so if the first character is a 1, it will be offset from the edge because that is literally how 7 segment displays work..

Here is the 7-segment font anyway, it's SIL OFL license: https://silverfish-freestuff.s3.amazonaws.com/TestStuff/7segment.ttf

The only other issue I found is that sometimes, but not always, when changing to a font with a different glyph size, the text renders all scrambled at first. changing the entity size fixes it instantly: Screenshot 2024-04-19 22 26 37

HifiExperiments commented 3 weeks ago

@SilverfishVR I've fixed the issue in the tutorial (I was calculating the space width wrong, so the text itself was slightly wider than it should have been), updated the docs to reflect that only PNG is supported, and pushed a possible fix for the text scrambling

SilverfishVR commented 3 weeks ago

Looks good. I did not see the issue with text scrambling and the tutorial text is good now šŸ‘

ksuprynowicz commented 3 weeks ago

Thanks for testing! Maybe we can merge it?

HifiExperiments commented 3 weeks ago

ready to merge from my end! I have some ideas for a follow up for how to get crisper text but those changes will be minor in the shader and Iā€™d like to get this in first.

thanks all!