Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question horrible flickering artifacts show up in distant text

Discussion in 'UGUI & TextMesh Pro' started by ebaender, Jul 17, 2021.

  1. ebaender

    ebaender

    Joined:
    Oct 29, 2020
    Posts:
    97
    Screenshot 2021-07-17 034611.png

    These ugly artifcats show up in a flickering fashion similar to z-fighting at a viewing distance of around 10 units with a 60 degree fov. The flickering is very rapid and distracting, and sometimes the whole text mesh gets blacked out completely.

    I've tried playing around with sample point size and padding, but that hasn't had any effect on the issue. Also tried changing size in the debug settings to no avail.

    These are my font and text mesh settings:

    Screenshot 2021-07-17 035331.png Screenshot 2021-07-17 035504.png
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    It is possible that the issue is caused by the very small scale that you are using which forces you to use a point size of 0.24 on the text object. This in turn may affect the SDF Scale computation where we could be running into floating point precision.

    Just for testing, see if switching to the "TextMeshPro/Mobile/Distance Field SSD" shader resolves the issue?
     
    ebaender likes this.
  3. ebaender

    ebaender

    Joined:
    Oct 29, 2020
    Posts:
    97
    Thanks for your help! I tried the shader you suggested, it does not make any difference.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Are you using UPR or HDRP or is the with the normal render pipeline?

    See if adjusting the scale of your objects / scene has any affect on this? Just trying to rule out potential scaling type issue?

    Is the in the editor?

    Do you get this with all font assets or just a specific one?
     
  5. ebaender

    ebaender

    Joined:
    Oct 29, 2020
    Posts:
    97
    I'm using the builtin render pipeline, all fonts cause the issue, and scale only affects the distance at which the artifacts start appearing. The artifacts don't show up in the editor for some reason, neither in the scene nor the game view. I checked if antialiasing had something to do with it since that's not applied to the editor views, but the artifacts show up in the build even if there is no antialiasing.
     
  6. ebaender

    ebaender

    Joined:
    Oct 29, 2020
    Posts:
    97
    Found the culprit! Sorry for the confusion, this actually had nothing to do with TMP at all.

    The artifacts look like z-fighting because they are z-fighting! The front and back face of the paper model behind the text mesh are too close together, which coincidentally only becomes apparent at about the same distance where individual letters in the text start flickering because they're taking up less than a pixel.

    Since the color and the bounds of the artifacts match the text mesh pretty much exactly I didn't even consider the paper behind it being the problem. It makes sense though, the back face is completely black thanks to the shadowmap and the paper mesh has a completely flat rectangular face in the center which just so happens to align perfectly with the text.