Search Unity

TextMesh Pro Text disappears when pivot (centre point) goes off screen

Discussion in 'UGUI & TextMesh Pro' started by jonahyakuto, Nov 22, 2019.

  1. jonahyakuto

    jonahyakuto

    Joined:
    Mar 9, 2017
    Posts:
    11
    We're modifying the TextMeshPro's mesh in runtime to achieve the shadow effect you can see below. However, upgrading to a version later than 1.3.0 makes the text disappears when its pivot goes off the screen.

    Is it possible to have the behaviour from 1.3.0 in 2.1.0+? If so, can you point me to the right direction? I've been fiddling with the shaders to no avail. I attached the test script used in the gifs below.

    v1.3.0
    1.3.0.gif

    v2.1.0preview2
    2.1.0preview2.gif
     

    Attached Files:

    • Test.cs
      File size:
      1.9 KB
      Views:
      428
  2. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,768
    You need to update the bounds on the mesh.
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Any reason you are creating the shadow by duplicating the geometry / object instead of using Underlay on the Material?
     
  4. jonahyakuto

    jonahyakuto

    Joined:
    Mar 9, 2017
    Posts:
    11
    Using Underlay restricts us on how much offset we can have without having a large padding that will cause us to have bigger atlas or have a smaller point size which cause the text to become soft. Both are not desirable with our constraints.
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Increasing the Underlay range does indeed require increasing padding values. As you stated, this does impact sampling point size and texture space.

    How much range do you need on the Shadow? For instance, a ratio of Sampling Point Size to Padding of 20% usually provides decent range. Sampling point size should be within 72 to 120 point size depending on the type face complexity. It is rare to need higher sampling. Asian character usually work well between 36 - 48.

    Do you need this depth of shadow on all text or just titles? If just titles, it might make sense to use a different font asset and texture just for those few characters.

    Just looking for a better understanding of the use case given it is unusual to have shadows that extend far away from the text outside of world space type usage where for those use cases, using a Surface / lit shader where the text object casts a shadow in the scene usually works best.

    P.S. I'll take a look at the initial report / pivot relationship and culling.
     
    Last edited: Nov 25, 2019
  6. jonahyakuto

    jonahyakuto

    Joined:
    Mar 9, 2017
    Posts:
    11
    It's being used for both titles and regular text. An example would be if the font size of a text is 12 and requires a 4pt vertical offset, the padding would then need to be around 33%.

    We're basically mimicking how Unity UI Shadow does it; but we're not using Unity UI and all our UI items are in world space.

    Much appreciated!
     
  7. Meatloaf4

    Meatloaf4

    Joined:
    Jul 30, 2013
    Posts:
    183
    I'm having this exact same issue. Was this ever resolved?
     
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The text object should remain visible until its bounds are outside of the camera view.

    Having said that, this wasn't always the case so please test with the latest release of the TMP package which is version 3.2.0-pre.3 for Unity 2020.3 or newer. Be sure to re-import the TMP Essential Resources as the shaders have changed in these most recent releases.
     
  9. Meatloaf4

    Meatloaf4

    Joined:
    Jul 30, 2013
    Posts:
    183
  10. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The culling is definitely handled differently between the Canvas and the Mesh Renderer. On the normal TMP text object's mesh renderer, you can disable Dynamic Occlusion. When you do so, does that make the object remain visible?
     
  11. Meatloaf4

    Meatloaf4

    Joined:
    Jul 30, 2013
    Posts:
    183
    Unfortunately not, that was one of the first things I tried :(
     
  12. Grelle_IA

    Grelle_IA

    Joined:
    May 15, 2023
    Posts:
    7
    Unity 2022.1, TMPro 3.2.0-pre.4
    Similar problem, but my text dissappear when its edge touches screen's edge (not pivot!).
    And when I this text is visible in "screen" tab, it's working nice in "game" tab.
    It seems to be ok in build, but in editor there is some strange behaviour =_=.