Search Unity

Bug Text getting frustum culled due to incorrect mesh bounds

Discussion in 'UGUI & TextMesh Pro' started by Brady, Aug 2, 2021.

  1. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    I have a case where if the entirety of a TextMeshPro object's text comes from a fallback font, meaning it will have to create a submesh, then the bounds of that submesh remain at the local origin and do not encompass the extents of the text that it inside the submesh.

    So for example, if I have text that is 100% translated to Chinese, those Chinese characters come from a fallback font I have. Meaning the main TMPro object has no content of its own, and thus has mesh bounds of 0x0x0, and all the text instead appears in the submesh created at runtime as a child to it. But it seems as though submeshes somehow inherit the bounds of their parents. So if the parent's bounds are 0x0x0, then is the submesh.

    This means that when the pivot point of the parent TMPro goes out of frustum, the entire text disappears because it gets frustum culled based on its extents, which are zero.

    I've thus far not found a way to force the submesh's extents to be computed by the actual geometry/characters it contains. Any help would be AMAZING.

    Thanks!
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Please make sure you test with the latest release of the TMP package (if that is not the case already) as I made some recent changes related to this. Let me know if the behavior is the same there.

    P.S. I just tried reproducing the behavior you outlined above but everything rendered as expected. So if you are still running into this potential issue in the latest release, can you please provide a simple repro project for me to look at?
     
    Last edited: Aug 2, 2021
  3. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    I'm on 2.1.6 and still having the problem (2019.4.26f1). I'll try to put together a sample project.
     
    Stephan_B likes this.
  4. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    @Stephan_B, it looks like it has to do with VR/XR. You can even replicate the issue by deleting the camera in a test scene. Without a camera in the scene, moving the sceneview camera to an orientation where the pivot of the TMPro object is out of frustum should cause the entire piece of text to get culled. This is what clued me into the fact that it is somehow related to the camera. Converting the MainCamera to an XR Rig fully replicates the issue I'm having in my own project. Something about when the camera becomes an XR rig camera causes TMP not to cull correctly anymore.

    Strangely, if you just create a default camera in the scene, the problem cannot be reproduced. Only if you either delete all cameras, or use an XR rig.

    Sample project linked here:
    https://drive.google.com/file/d/18f-JTYJ8uIgbtCCSbMGhtJHfxb6VNaiM/view?usp=sharing

    Repro steps with the sample project:
    1. Open SampleScene scene
    2. Press Play
    3. (Automatic) The text in the TMPro object gets changed in Start() by a component I placed on it, populating it with characters that force it to exclusively use the fallback font (arial unicode).
    4. Pivot the scene view camera around so that the transform center of the TMPro object passes just outside the left or right edge of the sceneview. This should cause the entire visible text to suddenly disappear. Make sure to try both sides to really see the problem.
    How to reproduce this with an empty project:
    1. Import TMPro and essentials.
    2. Import XR Plugin Management (and possibly XR Legacy Input helpers)
    3. Click GameObject > XR > Convert Main Camera to XR Rig
    4. Add arial unicode as a dynamic font and set it as the fallback.
    5. Add TextMeshPro text object to scene, keeping the font at the default Liberation Sans.
    6. Write a script that assigns some Chinese text to the TextMeshPro text in Start().
    7. Press Play
    8. Pivot sceneview until text disappears.
     
  5. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Were you able to reproduce the issue with the above?
     
  6. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Please check the sample project I provided above and let me know once you have so I can take it down.
     
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    I downloaded the project. I will try to take a look at it over the weekend.
     
    Brady likes this.
  8. Nifflas

    Nifflas

    Joined:
    Jun 13, 2013
    Posts:
    118
    I have this exact issue too! I'm not using VR. Are are any news about it?