Search Unity

TextMesh Pro Seeing pixelated text when scaling up scene

Discussion in 'UGUI & TextMesh Pro' started by nlezotte_zspace, Aug 1, 2018.

  1. nlezotte_zspace

    nlezotte_zspace

    Joined:
    Feb 9, 2015
    Posts:
    2
    We are running into an issue where TextMesh Pro UI text in some of our scenes looks great, but in other scenes it looks very pixelated. As far as we can tell, the main difference between the two cases is that the scenes that look good are at a smaller scale than the scenes that look pixelated. In particular, in the scenes that look pixelated, the objects in the scene are about 50x as large (in terms of world space units) as the objects in the scenes that look good.

    Is there any logic in TextMesh Pro that might be affected by the scene scale and impact the rendering quality? If so, is there any way to configure TextMesh Pro to ignore the scene scale or to compensate for it?

    A few other pieces of information that may or may not be relevant:
    1. We are using Unity 2017.3.1 with TextMesh Pro 1.0.56.

    2. We are attaching our UI text to a world space canvas.

    3. Our applications use quad-buffer stereo rendering through Unity's stereo camera support to draw to custom stereo display hardware. As part of this, we introduce an additional scale factor in the scene through the left/right eye stereo view matrices that Unity exposes on its camera. This extra scale factor is needed to make a correspondence between the physical space around our display hardware and the world space of the Unity scene (we do this to allow interaction between physical objects and the Unity scene).

      • We suspect that this extra scale factor might be what is causing the issue since TextMesh Pro probably does not know how to take it into account automatically. However, we are not sure if there is any way to explicitly configure TextMesh Pro to compensate for this extra scale factor.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    In order for the text to render correctly (when using Signed Distance Field), scaling information is passed to the shader.

    As such it is likely that your alteration of the scaling is resulting in incorrect scaling information being passed to the shader. This SDF scaling is encoded in the UV2.y of each vertices.

    You can see how this is handled for lossy scale changes by looking at the UpdateSDFScale function in both TMPro_Private.cs and TMPro_UGUI_Private.cs. Also look for the following region in the code "Handling of UV2 mapping & Scale packing", which is where this is set on UV2.y.

    There are different ways you could adjust the SDF scale for your needs. You could certainly modify the source to add support for your additional scaling changes. You could also do some post changes in UV.y similar to how scripts in the Animating Vertex Attributes example scene change vertex data.
     
  3. nlezotte_zspace

    nlezotte_zspace

    Joined:
    Feb 9, 2015
    Posts:
    2
    Thanks for the quick reply. I installed Unity 2018.1.9 and got the TextMesh Pro source via the Unity package manager.

    Based on your description and what I am seeing in the source, we are going to try tweaking the TextMesh Pro SDF shader to add a new float uniform that we will multiply by the scale passed in via the UV coordinates. I think this will be a simpler way for us to apply our other scale factor globally across all text components that use our font asset.

    I will report back if we run into any problems with this approach.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Let me know how it turns out.
     
  5. Joy-Kumar

    Joy-Kumar

    Joined:
    May 31, 2016
    Posts:
    1
    Would be great if we can have a reference. Thankyou. @Stephan_B and @nlezotte_zspace
     
    Last edited: Mar 16, 2022