Search Unity

TMPro graphic bug, help!

Discussion in 'UGUI & TextMesh Pro' started by ewat, Nov 8, 2019.

  1. ewat

    ewat

    Joined:
    Jul 3, 2017
    Posts:
    1
    I've imported the Nixie One font from Google and imported it through the Font Asset Creator.
    I've tried using both the Canvas as a world space canvas and also as a 3D object but the result is the same.
    I couldn't attach a video, but here's a youtube video


    As you can see, it flickers as if it's Z fighting. It does this regardless of it's embedded in an object or not.
    When I use the TMP bitmap shader everything works fine.

    Am I importing the font incorrectly?
    Unity_2019-11-08_16-23-56.png

    Thanks in advance!
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The issue appears to be related to the ratio of Sampling Point Size to Padding being too small. See the following post and linked FAQ.

    To provide additional insight, a good Sampling Point Size for most Latin based characters is between 72 and 120 point size depending on the complexity of the font itself. The Default Sampling Point Size for Dynamic Font Assets is 90. For most Asian characters, a sampling of 36 to 48 actually works pretty good but like I said, it is dependent on the font itself.

    Higher sampling point size mean better accuracy in the sampling / reproduction of the characters.

    The ratio of Sampling Point Size to Padding determines the effective range of Material Properties like Dilation, Outline, Underlay, etc. A good ratio is 10%. So if the Sampling Point Size is 90 than a padding value of 9 would work nicely.

    The larger the percentage, the thicker the Outline can be and the longer range / offset the Underlay / Shadow can have.

    Given the number of characters you can fit in a given texture size is directly related to Sampling Point Size and Padding, you need to balance the Sampling Quality and Padding. So when creating a font asset, you have to consider how you will be using this font asset. If the text will mostly be plain white text with limited Outline, Shadow, etc. then maximizing the sampling point size and using a smaller padding value / ratio like down to maybe 5%. But if the font asset will be used for big titles with Outline and deep Shadows, then you might want a larger padding value / ratio maybe 15% to 20%. When you are not sure, a ratio of 10% good.

    When the Ratio of Sampling Point Size to padding is too small and as per the FAQ linked above, your will get those visual artifacts.

    Although I can't see what the Sampling Point Size is in your font asset, given the texture size is 2048 x 2048 where the asset includes only the ASCII characters, the Sampling Point Size is too large and the Ratio given the padding is 5, too small thus resulting in these artifacts / flicker.

    Regenerate the font asset targeting something closer to 72 - 100 with padding value at around 10%. Reducing the texture size to 1024 X 1024 should get your close.