Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

All UI text looks bad

Discussion in 'UGUI & TextMesh Pro' started by kamac, Jun 18, 2018.

  1. kamac

    kamac

    Joined:
    Mar 21, 2014
    Posts:
    13
    Hey. I've been trying to get unity to render UI text as crisp as possible, but I just can't seem to get it right. I've tried dynamic setting, unicode with increased font size and setting font texture's filtering to point. I even tried TextMesh Pro, but to be honest I haven't noticed a significant difference.

    Here's how Open Sans looks for me at text size = 12, with font settings being (from top to bottom):
    1. font size 12, rendering mode "hinted smooth", character "unicode"
    2. font size 24, rendering mode "hinted smooth", character "unicode"
    3. font size 48, rendering mode "hinted smooth", character "unicode"
    4. font size 64, rendering mode "hinted smooth", character "unicode"
    5. font size 12, rendering mode "smooth", character "dynamic"
    6. font size 12, rendering mode "smooth", character "dynamic"



    Is this as good as Unity's text rendering gets? Could this be somehow related to my canvas scaler? I have it set at Constant Pixel Size, with scale factor = 1 and reference pixels per unit = 16 (though I haven't noticed this to affect text rendering at all)
     
    dadude123 likes this.
  2. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    So honestly yes, with the default UI text the rendering is not very clear. TextMesh Pro should solve this issue for you though so i'm surprised when you say "but to be honest I haven't noticed a significant difference.". By chance do you have pixel perfect on or off (Canvas setting)? You can get around any performance costs of pixel perfect by ensuring the rect transform bounds for the text objects are at whole numbers for both position and size, even fractions of pixel off could make it look even worse.
     
  3. kamac

    kamac

    Joined:
    Mar 21, 2014
    Posts:
    13
    Thanks for the reply! Yes, unfortunately TextMesh Pro looks very similar (the bottom one is TextMesh Pro with 16bit SDF, font import and material settings left default, both text sizes set at 12)



    I have pixel perfect setting turned on, but it doesn't seem to change anything. I'd like to try it with different unity version, as I am on 2017.4.1f1 right now. I suppose it's unlikely it's a bug? I haven't noticed any changes to text rendering in unity changelog for the version I'm using, or for 2018.
     
  4. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Take a look at this: https://forum.unity.com/threads/how-to-get-consistent-small-text.535345/

    Essentially BitmapFont + SDF shader can get you much better results after some tweaking.
    No response from anyone there still, but at least there are some ways.

    Downside is not being able to set any kinds of outlines on the text though, and probably some more stuff.
    which could be fixed by taking a SDF atlast and essentially "pixelating" the glyphs so you get crisp text and outlines.
     
  5. kamac

    kamac

    Joined:
    Mar 21, 2014
    Posts:
    13
    Alright, I've tried more presets, and it looks best with bitmap prerendered at 12px. Too bad there's some kind of bug present that won't let me change the color of my text from black (even though the prerendered font bitmap clearly has white characters [edit: actually the atlas contains black characters...]).


    Point 5 is the same font rendered by GIMP. As you can see, all unity rendered texts look bad (to the point that there's little gain to using TextMesh Pro). Is this really impossible for us to get text rendering in unity up to par with point 5?
     
    Last edited: Jun 18, 2018
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    When rendering small text using SDF, make sure you enable Extra Padding in the text object inspector. Switching to Linear Color space should also help when rendering SDF text.

    I will take a closer look later today using this OpenSans font to compare what results I get on my end and post the results.
     
    CodeRonnie likes this.
  7. kamac

    kamac

    Joined:
    Mar 21, 2014
    Posts:
    13
    I've tried enabling Extra Padding [text no. 2], and it got rid of some letters appearing malformed/too thin at times, at the expense of added shadow. However, setting the color space to linear butchers the effect [text no. 3].



    Also it's worth noting that the text prerendered by GIMP in my previous post doesn't even use subpixel rendering.

    EDIT

    After fiddling with lots of different settings for SDF, here's the best I could come up with:

     
    Last edited: Jun 18, 2018
    dadude123 likes this.
  8. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Any success with that? Anything we can do to help? Would a repro project help?
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Repro projects are always a great time saver on my end. So always feel free to send those my way :)
     
  10. kamac

    kamac

    Joined:
    Mar 21, 2014
    Posts:
    13
    Here you go. I attached a repro project.
     

    Attached Files:

    Stephan_B likes this.
  11. FBones

    FBones

    Joined:
    Aug 28, 2016
    Posts:
    73
    @kamac , have you tried unchecking "Low Resolution Aspect Ratios"? It makes a big difference.
     
  12. unity_2OuSjDXJNNAZ6A

    unity_2OuSjDXJNNAZ6A

    Joined:
    Mar 27, 2018
    Posts:
    1
    Any updates on this, or potential workarounds?
     
    brainwipe and Avalin like this.
  13. Andy608

    Andy608

    Joined:
    Jun 17, 2017
    Posts:
    18
    @Stephan_B were you ever able to take a look at this? I've noticed consistent text rendering blurriness with Unity ever since I started using it. Any additional info would be great to hear how we could get crisp text in our games.