SDF Font Rendering - Test Release

Discuss Daggerfall Unity and Daggerfall Tools for Unity.
User avatar
Interkarma
Posts: 3620
Joined: Sun Mar 22, 2015 1:51 am

SDF Font Rendering - Test Release

Post by Interkarma » Sun Aug 26, 2018 6:23 am

I'm trying a limited test release for new font rendering tech in Daggerfall Unity. I've completely overhauled the way text is rendered in game to make it faster, use less memory, and look nice and smooth at high resolutions. Here's the rundown.
  • You can now choose between classic or SDF (signed distance field) font rendering. Classic rendering looks just like old-school Daggerfall, and SDF rendering uses a new font type that looks much better at high resolutions. If you're playing in HD, you probably want to enable SDF font rendering.
  • Both styles of fonts are now drawn by a GPU shader. Previously intensive tasks such as restricting text render area are now very cheap and efficient.
  • You can enable SDF font rendering on the startup page or toggle at any time using Shift+F11.
  • You can supply replacement SDF atlases in StreamingAssets/Fonts. SDF font atlases need to be prepared in a special way before they can be used. I'll write up an article about this soon.
Fonts should "just work" and look great in either classic or SDF format, with a few limitations.
  • Most classic UIs have baked-in text. Only dynamically rendered text will appear at SDF quality.
  • Exterior automap uses a legacy way of presenting fonts for nameplates. This will need to be updated at some point to support SDF fonts.
  • SDF fonts have to render characters in the same positions as classic, which can lead to letters looking a bit squished or stretched. I've done as much as possible to limit the the effects of this while maintaining the layout defined by books, quests, etc. exactly as classic.
  • Translation mods use custom fonts. Users playing with translations should continue using classic fonts until a converted SDF version is available.
And here are the downloads:

Windows
PreAlpha 0.5 #128 26-Aug-18 (get 64-bit)

Linux
PreAlpha 0.5 #128 26-Aug-18

Mac
PreAlpha 0.5 #128 26-Aug-18

Please let me know your feedback and if any problems are encountered. Once I'm confident nothing is broken with text, I'll drop another round of Live Builds.

User avatar
Interkarma
Posts: 3620
Joined: Sun Mar 22, 2015 1:51 am

Re: SDF Font Rendering - Test Release

Post by Interkarma » Sun Aug 26, 2018 6:29 am

Example screenshots 1-3.
fontrendering1.png
fontrendering1.png (1.62 MiB) Viewed 747 times
fontrendering2.png
fontrendering2.png (873.07 KiB) Viewed 747 times
fontrendering3.png
fontrendering3.png (1.22 MiB) Viewed 747 times

User avatar
Interkarma
Posts: 3620
Joined: Sun Mar 22, 2015 1:51 am

Re: SDF Font Rendering - Test Release

Post by Interkarma » Sun Aug 26, 2018 6:30 am

Example screenshots 4-6.
fontrendering4.png
fontrendering4.png (125.79 KiB) Viewed 746 times
fontrendering5.png
fontrendering5.png (824.33 KiB) Viewed 746 times
fontrendering6.png
fontrendering6.png (795.45 KiB) Viewed 746 times

User avatar
Nystul
Posts: 1198
Joined: Mon Mar 23, 2015 8:31 am

Re: SDF Font Rendering - Test Release

Post by Nystul » Sun Aug 26, 2018 2:22 pm

I will take a look on the exterior automap nameplates as soon as I find the time to do it ;)

User avatar
Interkarma
Posts: 3620
Joined: Sun Mar 22, 2015 1:51 am

Re: SDF Font Rendering - Test Release

Post by Interkarma » Sun Aug 26, 2018 8:45 pm

Thank you Nystul. :)

The gist of things is the text must be pre-processed for SDF (I've already done this for default replacement fonts) and must be drawn with a special but rather simple fragment shader. The trick will be getting the correct texture data as the source.

I've retired the old way of generating a texture for each and every label presented. Now I just generate the layouts and the shader takes care of drawing and stuff like restricted render areas. It's faster and uses less memory. I still generate a texture when requested just for the exterior automap, and I'm happy to preserve this method going forwards if that's easiest for you. It wouldn't take much to get either an SDF or classic texture back from the label class.

Ideally, we should be able to discard with the custom font instance for nameplates and colour text using vertex properties or the shader itself. This saves on having another copy of font data in memory just for automap and still gives you full control over the text appearance. This is a much more flexible situation than we started with.

User avatar
Nystul
Posts: 1198
Joined: Mon Mar 23, 2015 8:31 am

Re: SDF Font Rendering - Test Release

Post by Nystul » Mon Aug 27, 2018 6:25 am

Ideally I would aim for a solution that just uses the shader to render nameplates - not sure how straight-forward this is ;)

User avatar
pango
Posts: 435
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: SDF Font Rendering - Test Release

Post by pango » Mon Aug 27, 2018 4:00 pm

Hi,
I give it a try, and they're some oddities (to my layman eyes); For example when trying to interact with a merchant, "TALK" option will use a classical bitmap font, while "Sell" will be written with the new font.
I assume that in such screen there's a mixture of text hardcoded in the form and text dynamically rendered on top?
Of course there's hardcoded text in other graphic resources, but that case seems particularly complicated to fix...
Attachments
talk sell.jpg
talk sell.jpg (71.24 KiB) Viewed 613 times
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Interkarma
Posts: 3620
Joined: Sun Mar 22, 2015 1:51 am

Re: SDF Font Rendering - Test Release

Post by Interkarma » Mon Aug 27, 2018 8:18 pm

The "Talk" is baked into the UI, not dynamic text. Anywhere you still see classic-looking pixel text, it's baked into UI itself. :)

I agree it's a bit incongruous, but updating baked text isn't the focus at this time. Best way to do this now is through mod system by replacing UI image.

User avatar
Hazelnut
Posts: 938
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: SDF Font Rendering - Test Release

Post by Hazelnut » Sun Oct 28, 2018 9:38 pm

Bit late here on this thread, but after working on the journal this week I just wanted to say how frikken awesome these SDF fonts are. At the time I was just thinking great, a nice font, and that was it. However towards the end of developing the new journal stuff I realised I'd done all the work with the SDF fonts turned on so I thought I ought to see what it looked like with the old pixelated fonts which I'd been fine with before.

Switched it and when I popped up the notebook tab it looked so terrible in contrast. :-D

This update was huge, and you only realise when you switch back just how much nicer on the eyes it is!

User avatar
Interkarma
Posts: 3620
Joined: Sun Mar 22, 2015 1:51 am

Re: SDF Font Rendering - Test Release

Post by Interkarma » Sun Oct 28, 2018 10:23 pm

Thank you mate, I appreciate the feedback. :)

As much as I love the retro UI look, I found the classic fonts a bit hard on the eyes after a while. On my 15" CRT monitor back in the day, there was an inherent blurriness that smoothed them out a lot. But on a 30" UHD LCD monitor those old fonts are so crisp and blocky I struggle to read them after a few hours. Now the SDF fonts look amazing in UHD and my eyes are thanking me.

BTW, your notebook implementation is incredible! I'm putting together some screenshots for a quick article now. I was just going to drop a bug-fix release, but the notebook was just too good not to include and highlight.

Post Reply