Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

TextMesh Pro TextMeshPro displays white blocks when changing localscale in world space UI

Discussion in 'UGUI & TextMesh Pro' started by kryzodoze, Mar 7, 2018.

  1. kryzodoze

    kryzodoze

    Joined:
    Nov 6, 2013
    Posts:
    21
    I've isolated what I think is a bug. Here are steps to reproduce:

    1) Open new scene
    2) Create UI image
    3) Create 'TextMeshPro - Text' element (Under UI)
    4) Attach the text element as child of image
    5) Attach a script to image that modifies localscale (I've attached a basic one)
    6) Change canvas to be 'World Space' render mode
    7) At runtime, change localscale of image dynamically via script
    8) Text turns into white boxes


    Unity 2017.1.3f1
    TextMesh Pro 1.0.56.0b3
     

    Attached Files:

  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    In order for the Signed Distance Field text to render correctly, scaling information is passed to the shader. Although this used to require the scale of the text object be uniform (which is still preferable otherwise the text is distorted), you still need to make sure the x, y, z scale not be zero otherwise no text or white blocks.

    So revised your script to keep the z scale uniform with the x and y.

    P.S. Make sure that you assign a camera to the Canvas when using a Canvas in World Space.

    P.S.S. Unless you need to use the Canvas system, for World Space user, I recommend using the normal <TextMeshPro> component which works with the Mesh Renderer. This is more efficient for world space as the Canvas system does add a fair amount of overhead. This normal TMP component is located in "Create - 3D Object - TextMeshPro - Text".
     
    Last edited: Mar 8, 2018
    elguncumayev and DranrebKing like this.
  3. kryzodoze

    kryzodoze

    Joined:
    Nov 6, 2013
    Posts:
    21
    Thanks a lot man, that did it. We were racking our brains over this for quite awhile today.

    If you're ever near the zSpace office, we'll buy you a beer. :D
     
    Stephan_B likes this.
  4. DranrebKing

    DranrebKing

    Joined:
    Jun 3, 2018
    Posts:
    4
    Thanks a lot! this helped :)
     
  5. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    245
    Hello! Is it stil actual at 2020? On mobile device for some reason I see white squares when non-uniformly tweening / scaling text. but in Editor it's ok. Should we use uniform or reason may be in something other? Z scale isn't zero.
     
  6. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Instead of scaling from 0 to x... use 0.0001 to x which should get around the white square. Y has been the value that is tracked for potential scale changes to the text object.

    Let me know if adjusting your tweening values to replace 0 by 0.0001 does the trick.
     
    mitaywalle likes this.
  7. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    245
    Thank you for fast answer, we'll try ot out ASAP :)
     
  8. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    245
    Hello again! I've two cases of this, and in first uniform + clamp helped, but in second - not. I've checked lossyScale of text Transform and all its parents Transforms, - all are ok, no zero.
    Tryed:
    - moving TMP_Text closer to root
    - duplicating whole object
    - deleting geometry subobject
    - recreation of TMP_Text Component

    Only if I Duplicate TMP_Text outside of prefab / Canvas to simple scene helped.

    Now I've reacreated Transform too, waiting for build to finish to check result.
     
    Last edited: May 27, 2020
  9. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    It is not the lossyScale but the scale of any of the x, y, and z being zero.

    Another possibility for white block is a loss of the reference to the atlas texture.

    If you are able to reproduce one of these remaining scenarios, please submit a bug report with a project to reproduce the issue. It should be easy to identify the source of the issue when looking at the project but not as easy without it.

    P.S. Make sure that you are testing with the latest release of the TMP package which is Preview 13.
     
    GlenMcKnight likes this.
  10. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    245
    I've tryed to make repro-project, but in clean project with same Unity / TMP version problem disappear

    And we're using Unity 2019.2.2f1 and unfortunately can't upgrade engine and TMP to latest 'cause game-release deadline's ahead.
     
  11. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    245
    Also, texture is inside TMP_Font asset, which is in Resources folder, and there's other usages of this font / material in project and they look correct
     
    Last edited: May 27, 2020
  12. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    245
    Calling TMP_Text.ForceMeshUpdate() after enabling object helped! Thank you Stephan for help!
     
  13. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,444
    Having this pop up when working in editor on 2020.2.0a12 with worldspace UI using TextmeshPro, it only shows in the game view not the scene view. Works just fine in a build on the Oculus Quest though?
     
  14. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    What do you mean by Pop Up?

    Are these blocks persistent in the game view or just momentarily showing up?
     
  15. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,444
    Persistent white blocks around the text, only in game view, they get stronger in opacity when you move the game camera further back but not the scene view camera.

    Issue persists with 3.0.0 Preview 12 and 13 from my tests so far.
    @Stephan_B
    upload_2020-5-29_16-6-4.png
     
    Last edited: May 29, 2020
  16. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Ok. This is simply due to the ratio of Sampling Point Size to Padding being too small.

    For most use cases, you want a Sampling Point Size of something no larger than 90 point size and padding value of about 10% of 9 in this case.

    The solution is to regenerate your font asset to increase this ratio which is likely small right now.

    What is the Sampling Point Size of your font asset and padding value?
     
    ROBYER1 likes this.
  17. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,444
    Sampling point size set to Auto and Padding set to 5, those were the default values I never changed them. Will try playing around with them now although changing that for other fonts will be tedious!

    Edit: Just changed padding to 9, unselected auto for sampling point size, it was at 59 so I left it. Changed packing method to Optimum, generated then saved. It is fixed now. Most unusual this just cropped up when upgrading the package and engine version.

    I have had this scene working fine for 5-6 months now this issue has just cropped up, recently moved up 2 alpha engine versions on the 2020.2 alpha branch and upgraded TextmeshPro Package preview versions of 3.0.0 a few times during then also.
     
  18. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Did you change / adjust any of the material properties like Dilation or Underlay offset? This behavior would become visible as any property value get near the maximum range or 1 in most cases.

    In the Debug section of the Material Inspector there is also Scale X and Y whose value should be 1.0 for each. This could also cause this behavior. Then Sharpness as well and Perspective Filtering which you could test is a value of zero makes the issue disappear.

    Changes to camera settings or scale of the scene could impact this.

    Outside of that, maybe some other changes like texture settings / compression which should not be use on SDF textures at all.
     
  19. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,444
    This was really useful to know, thanks for writing this advice up.

    Effectively I left all settings at default when we started using TextMeshPro as everything it did looked fine. Then when upgrading alpha engine versions, something must have changed but nothing was changed on the fonts or textmeshpro font files since their creation.

    I usually have to change texture compression back to ESTC when changing engine version (through the build settings menu). So perhaps that interfered somehow? Even though the TMPro text looked fine when using ESTC before!
     
  20. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    245
    Also in our case reason was in Soft Mask plugin + TextMeshPro 3.2.0