Search Unity

One frame glitch with dynamic SDF

Discussion in 'UGUI & TextMesh Pro' started by Manufacture43, Nov 23, 2019.

  1. Manufacture43

    Manufacture43

    Joined:
    Apr 21, 2017
    Posts:
    140
    Hello,

    I'm using TMPro 2.0.1 with Unity 2019.3 and I noticed a small glitch of just one frame where the texture appears to be fully white or maybe just missing:
    upload_2019-11-23_15-24-18.png
    This is quite random and I could not manage to catch it or make a repro project exhibiting it yet.

    Anyone having the same issue? It happens on PC and on Switch

    Edit: managed to catch in the editor! In the inspector, the texture displays fine. Unfortunately, when I start the frame debugguer or make the scene view visible, the text in the game view magically gets fixed.
     
    Last edited: Nov 23, 2019
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    There are two potential cause of this behavior. The first would be the Async compilation of shaders which can be disabled in the Editor Settings.

    upload_2019-11-23_13-2-16.png

    The other possibility is SDF Scale which could occur if you are doing any type of scaling of the text object or any of its parents. Are you doing any type of animation or scaling of the text object?
     
  3. Manufacture43

    Manufacture43

    Joined:
    Apr 21, 2017
    Posts:
    140
    That async shader compilation setting is only for the editor right? My problem also happens in builds of the game so I don't think that's it. I'm going to try though, just in case. I'll let you know. EDIT: doesn't fix the issue.

    I'm going to check but I don't think there is any scaling done on the text directly. However, the parent transform is indeed animated with a zoom-in / zoom-out type of animation. Is there a way to disable that sdf scale?
     
    Last edited: Nov 26, 2019
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    SDF Scale is essential for the text to render correctly. This initial white block representing the letter occurs when the SDF Scale is 0 which is likely due to the animation state.

    Since there are many ways to setup animations, make sure the scale of the text object is uniform (X, Y, Z) all using the same values. Often the Z is left at zero. Double check the animation by stepping over each frame to see how this affects the scale of the text object.
     
  5. Manufacture43

    Manufacture43

    Joined:
    Apr 21, 2017
    Posts:
    140
    Indeed, having the animation never go completely to a scale of (0, 0, 1) but rather a small value like (0.01, 0.01, 1) seems to fix the issue. Thanks.
     
    Stephan_B likes this.