Search Unity

TextMesh Pro Underlay Offset X and Y limited to -1 to 1?

Discussion in 'UGUI & TextMesh Pro' started by AcidArrow, Jul 3, 2018.

  1. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    I was tweaking some fairly old TextMesh Pro materials and for Underlay settings, I had Offset X 3 and Offset Y -3. I wanted a bit more offset, so I tried to tweak it. As soon as I touched the sliders, they became clamped to -1...1.

    Is there a reason? I'm not sure why I can't offset the underlay more than 1. I used to be able to.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    As per FAQ Question 11, the effective range of material properties like Outline or Underlay is determined by the ratio of sampling point size to padding. The values are normalized from -1 to 1.

    By increasing the ratio of sampling point size to padding, the effective range can be increased.

    A value greater than -1 and 1 has never been possible. A value of -1 or 1 represents the maximum range of padding / spread of the signed distance field values.
     
    Program-Gamer likes this.
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    It was possible at some point, since I have materials with 3 and -3 values (which were created in a much, much older version of TMPRO).

    Maybe it was effectively the same as 1 and -1?

    I'm not sure you're correct though. I get why dilation and other effects are directly related to the padding, I'm not sure why offset is related to padding.

    Also, if I switch to debug mode, I can enter values that are beyond -1 and 1 and it has an actual effect.

    -1 ... 1
    Screen Shot 2018-07-03 at 08.58.29.png

    Switched to debug and entered -2 ... 2
    Screen Shot 2018-07-03 at 09.00.39.png
     
    Last edited: Jul 3, 2018
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Visual Effects like Outline, Underlay, etc. are all by products of using Signed Distance Field. When using SDF modes, the padding represents the spread or range of the computed distance field.

    A value of 1 is the maximum possible range of the computed range which also happens to be right at the edge of the adjacent character.

    Using a value of greater than 1 or as per image #2 shows parts of the adjacent characters.

    If you need a larger effective range on those material properties, you need to re-generate the font asset to use a larger ratio of sampling point size to padding. If you current font asset has a sampling point size of 80 and padding of 4 then your underlay offset will be about 5%. However, if the sampling remains 80 with padding of 8 then you will have twice the range.

    When creating a font asset, it is best to consider how it will be used. If the font will be mostly displayed as plain white text, then using a smaller padding value to maximize sampling point size makes sense. However, if the font will be heavily styled, then using a larger padding value / ratio of sampling point size to padding will be best. I typically try to use a ratio of 10% on the font assets I create. This give me good visual representation in terms of sampling and good effective range where I rarely feel the need to use values greater than 0.75 or 0.8.
     
    ccaner37 and Jiaquarium like this.
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    Yeah, you're right. I guess I'm just very confused on how I ended up with materials with -3 and 3 values. I could have edited them in debug mode I suppose, but I don't remember doing that, but it has been a while.

    It's all good. Thanks for the extra explanations.
     
    unity_yO-Ji0hII_M9Pw likes this.
  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    Since I got you here, do you mind answering another question:

    Appart from being able to readjust padding etc, is there any other reason to re-generate really old font assets? I believe some of the font assets we use are old (were generated in 2015, with whatever version of TMPro was current then), I'm wondering if there have been any improvements to the packing or the way the distance fields are generated.
     
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    In the TextMesh Pro UPM package version 1.2.3, I added support for remembering font asset creation settings which will make it easier to update font assets in the future. Other than this, there is no major reason to regenerate font assets at this time.
     
    AcidArrow likes this.
  8. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606

    Ahhhhh. Thanks for explaining the padding..

    I thought I had a broken textmeshpro install.. The Underlay(Offset) was not visible.

    Maybe 10 as a default padding value isn't the best value? .. or it can be automatically-proportionally set when the user chooses a different sampling point.

    Thanks again for the explanation
     
    Program-Gamer likes this.