Search Unity

How to use TMPro SDF shaders with custom artwork?

Discussion in 'UGUI & TextMesh Pro' started by JoeStrout, May 27, 2020.

  1. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    If I have some custom line-art image — say, a sign or diagram — and I generate an appropriate signed distance field of it, can I use this with one of the TMPro SDF shaders to draw a nice crisp image, getting the same benefit for my custom artwork that TMPro brings to text?

    I feel like this should be doable, but I'm a little fuzzy on the details.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Short answer Yes.

    There are different approach to this but the simplest is to use some free tool online that allow you to take some shape / SVG, etc. and add it to a custom font file which you can then use in the Font Asset Creator or dynamically to create your Font Asset.

    Think of Font Awesome which is a font file that contains shapes and symbols. In the end, it is the same as any other font file, where instead of characters they are shapes.

    In terms of custom artwork, this has to be line like not paintings.

    There should be a post around where a user created different shapes that could be combined / colors all using SDF. Search for mouse button example with SDF on the forum here. I provided information about this perhaps a month or two ago.