Search Unity

TextMeshPro Outline Not Working / Is Pixel perfect outline possible?

Discussion in 'UGUI & TextMesh Pro' started by emongev, Oct 21, 2019.

  1. emongev

    emongev

    Joined:
    Jul 5, 2012
    Posts:
    36
    I have an issue with TextMeshPro not showing me an outline with a font.

    The font is pixel art and managed to configure it so its 1:1 with the pixel matrix: (Shown Here)

    upload_2019-10-21_11-18-39.png

    However if i try to add an outline to it, I get nothing, no matter the thickness configured.

    I want an outline added so its 1 pixel thick around the text with sharp corners. Similar to this:

    upload_2019-10-21_11-23-35.png

    First of all, is it possible?

    Secondly, why cant i get the outline to show?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The ability to add a dynamic outline is a byproduct of using Signed Distance Field which requires the font asset be created using SDF render modes.

    The ability to add an outline, shadow, glow and other similar shader based FX is not available with bitmap shaders.
     
    1000Nettles likes this.
  3. emongev

    emongev

    Joined:
    Jul 5, 2012
    Posts:
    36
    Maybe I just don't understand enough of the subject, but the material is using the Distance Field shader, but for some reason it just works with letters not included in the font (possibly because it reverts to the default font).

    upload_2019-10-21_18-32-15.png

    Is it that Text Mesh Pro is categorizing the letters in the font as requiring Bitmap shader?
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Font Assets can be created using either Bitmap or Signed Distance Field modes.

    The bitmap modes are Smooth, Raster, Hinted Smooth and Hinted Raster.

    The Signed Distance Field modes are SDFAA and SDFAA Hinted which are to be used with Dynamic Font Assets whereas the other SDF modes like SDF16 and SDF32 are much slower but more accurate and should be used with the Font Asset Creator.

    Only Signed Distance Field font assets using one of the SDF shaders will be able to use SDF specific features like Outline, Shadow, etc.

    I recommend you watch the following video about Font Asset Creation which covers this information along with the Working with Material Presets video.

    There is an additional video covering the Dynamic SDF system as well.
     
    Bloodberet likes this.
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    One of the still valid use for bitmap fonts is pixel art when rendering everything at 1:1 and pixel aligned.

    Although you can still get good results with Signed Distance Field, you typically need to increase the sampling point size if you want to try to preserve the sharp corners when adding an outline. You should be able to find a few of the posts I have made about this here.

    It is also important to note the outline thickness is relative to the Sampling Point Size to Padding. It is normalized from 0 to 1. It is not in pixels. See the following thread / post.
     
  6. emongev

    emongev

    Joined:
    Jul 5, 2012
    Posts:
    36
    Great, thanks @Stephan_B Ill be sure to check them out but it seems to be that if I wanted to create outlines, I'd need to create a font atlas manually in which each letter has the outline burnt in.

    Does Text Mesh Pro support creating a custom atlas of letters and translating text to rendering from that atlas, or would I need to find another tool for that? :) Tried searching for it in the documentation but didnt find it.
     
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    If you are using a bitmap, that is correct. You would need an atlas texture for each permutation or variance.

    It does but it is a manual process. There are a few threads about this on the forum here. Here is one of them.

    Alternatively and depending on how many characters / shapes, you could also create a Sprite Asset and assign the appropriate Unicode values to those sprites which would also allow you to achieve a similar result without having to construct a font asset manually.
     
    Last edited: Oct 22, 2019
    Roman_Keivan likes this.
  8. emongev

    emongev

    Joined:
    Jul 5, 2012
    Posts:
    36
    Great! You're the best @Stephan_B thanks for all the help!