Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Text Mesh Pro - The Ultimate Text Solution for Unity - Powerful & Flexible - Advanced Text Rendering

Discussion in 'Assets and Asset Store' started by Stephan-B, May 29, 2014.

Thread Status:
Not open for further replies.
  1. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    409
    This is great - I was going to write the SDF code - but hey, why bother. This package is awesome.

    One question - I looked through the shaders, it doesn't look like you're doing anti-aliasing based on screen space derivatives - as per valve's alpha tested mag - http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf

    float scale = input.param.y;
    It seems like this should also use ddx / ddy. Any reason? Was this a compatibility thing?

    Not a huge deal - I can make the changes myself - I just want to make sure I'm not missing something.

    Image for reference.
    Screen Shot 2015-08-24 at 3.45.10 PM.png
     
  2. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    409
    The real use case here is moving, scalable text. If the camera moves, ideally I'd want the softness level to stay the same independent of size on screen, or screen resolution - typically for semi-procedural shaders this is done with screen space derivatives, afaik.

    It looks like outline, underlay could use this treatment, also.
     
  3. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I am not using screen space derivative because is requires shader model 3.0 instead of 2.0 which limits the # of devices it can run on and is slower. Instead scaling information is passed to the shader which is even more accurate. See the following post for more details.

    In terms of perceptive, that is where perspective filtering comes in which is located in the debug panel of the material inspector.

    Shaders that use screen space derivatives could be used which has the benefit of not having to pass scale to the shader but again, at the trade off of performance.
     
  4. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    409
    Makes sense. Anyway - the font, kerning, and the rest is well worth it. I can tweak the shaders myself. Thanks.
     
  5. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Play with the perspective filtering and let me know if that gets you the results you need.

    If you do end up with shaders / tweaks that you feel would be advantageous to include for certain usage, please let me know.
     
  6. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    409
    It's mostly apparent whenscrolling small-ish fonts, or small fonts with hard borders where the current setup really pulses. I didn't have a good way to demonstrate that, so I uploaded the perspective image. I don't really intend to use text on-axis.

    Target hardware is console / high end pc - so fwidth or ddx & ddy aren't going to matter to me.

    Your solution looks pretty good already - it looks like what I'm running into is the physical geometry size. At small screen sizes I need the quads to scale up to allow for more smoothing. I hacked the 'smoothness' for that, for now. A quick test, hacky - worked pretty well on tiny text.

    Code (CSharp):
    1. float filterwidth(float2 v)
    2.         {
    3.          float2 fw = max(abs(ddx(v)), abs(ddy(v)));
    4.          return max(fw.x, fw.y);
    5.         }
    6.  
    7. .... pixel shader
    8. half d = tex2D(_MainTex, input.texcoord0).a;
    9. half wid = filterwidth(input.texcoord0);
    10.      half sd = smoothstep(0.5-25*wid, 0.5+50*wid, d );
    Really Tiny Before:
    Screen Shot 2015-08-24 at 6.03.16 PM.png

    Really Tiny After:
    Screen Shot 2015-08-24 at 6.02.45 PM.png

    I can't readily demonstrate the lack of flicker when scrolling - but that is markedly improved, too.
     
  7. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    409
  8. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Quick tip, when dealing with small text, it helps to turn on Extra Padding to avoid clipping. It is also very beneficial to switch Unity to Linear Color Space.
     
    hippocoder likes this.
  9. sschaem

    sschaem

    Joined:
    Feb 14, 2014
    Posts:
    148
    The shader do perform its anti-aliasing using screen space distances.

    The reason that you dont see any pixel shader derivatives code is that the ratio calculation is done in the vertex shader.
    This make the pixel shader simpler and compatible with all model 2.0 HW

    This is why you see input.param.y being passed by the vertex shader,
    its the interpolated per vertex HW screen space distance scaling ratio.
    This is used to convert the distance value sampled from the texture into screen space distances
    (instead of the per pixel derivative as in the Valve method)

    side note: the SDF cant be arbitrarily sampled without getting error distortion.
    So without special processing, distances will deviate from what is mathematically expected.
    Like non nonuniform scaling, or 3D perspective. (texels are no longer square)

    But with most perspective text, it should look alright. (old TMPro unity test screenshot)
    aniso.png




    note: some manual control over the 'filtering' was later exposed by the shader to manage more extreme perspective cases.

    From your screenshot, try to increase the 'padding' of the SDF.
    Just as a test, double what you have it set at right now, and compare. You might see a big difference....

    Quick reasoning: because the SDF is stored in 8bit, its ranged optimized.
    When you look at the atlas generated, all the black part and white part are clamped distance (invalid distances).
    So if you get to sample this clamped distance space (this can happen when you shrink something super small), you will get bogus distances.
     
  10. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    409
    I'm running in linear.

    Padding helps the movement flicker, although I'm seeing some screen space dependent issue with the default shader, where it appears to be nonuniform


    Non-uniform fuzziness based on screen position.x
    Screen Shot 2015-08-24 at 6.22.23 PM.png
     

    Attached Files:

  11. sschaem

    sschaem

    Joined:
    Feb 14, 2014
    Posts:
    148
    To clarify, using ddx/ddy should show no visual benefits as the ratio computed should be mathematically identical.

    Same font large, small. no pixel derivative used.

    The edge flicker on small text when moving should come from not using vertex padding.
    (vertex position are screen pixel clamped)

    cursive2.png

    Closeup of sub-pixel motion in TMPro SDF VS TMPro bitmap
    subpz2.png
     
    Last edited: Aug 24, 2015
    hippocoder likes this.
  12. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    This is where that Extra Padding options is located.

    upload_2015-8-24_15-37-1.png
     
    hippocoder likes this.
  13. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    409
     
  14. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    What version of TextMesh Pro and Unity are you using, Brian?

    P.S. Set perspective filters to Zero in the Debug section of the Material inspector.

    upload_2015-8-24_18-59-20.png
     
    Last edited: Aug 25, 2015
  15. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    409
    Unity 5.1.2 - Just purchased TMP today - so latest - Asset Store says 0.1.5 beta 2.2
     
  16. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    See my P.S. to previous post and let me know if that makes a difference in your tests.
     
  17. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    409
    Yep - perspective filter nailed it.
     
  18. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    This is something that I had revised due to changes in Unity 5 but maybe I somehow reverted back at some point of maybe Unity changed something again. At any rate, glad we now know why you were getting that result.
     
  19. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    It's getting there :)

    Here is an example of using 3 different Font Assets along with Inline Graphics (Sprites) in a single text object.

    upload_2015-8-26_0-59-1.png
     
  20. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Multi Font & Material + Sprites
    Decided to test the Reveal script that I used a while back. This is a single text object which contains 4 fonts and sprites.



    Although this text objects uses multiple fonts and sprites, the layout of the text is independent of those things and thus in this implementation, rich text tags, text formatting, word wrapping and all other features of TextMesh Pro are still available.

    I am not done with the implementation of these new capabilities but it is getting there.

    P.S. I wish GIF compression wasn't so bad but you get the idea :)
     
  21. troien

    troien

    Joined:
    Jan 15, 2013
    Posts:
    9
    I have a question.

    I'm creating something in which I want to place emoticons inside a Text component. And because of the videos I've seen about this product I think it might be what I'm looking for. However, I want to download the emoticons at runtime and use them.

    My idea is that I download an emoticon using WWW.texture and then if nescessary try and convert this to a sprite using Sprite.Create. But could your code accept this? (Adding either a Texture2D, Texture or Sprite at runtime to the Sprite Asset). Because in all the examples i've seen so far, this is done in the editor. I know that if this works it would probably destroy batching because every sprite I create uses a different texture. But that is a different problem :p

    If not, would it be possible to create a new 'Sprite Asset' at runtime supplying it with an array of sprites that do share the same texture (implying that I tackle the problem of packing my downloaded textures together into one texture).

    If it doesn't support this, is there any chance that this will be supported in the future?
     
    Last edited: Aug 27, 2015
  22. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The process might actually be easier. The Sprite Asset simply contains a reference to a texture and information about each of the sprites that it contains. Assuming the sprites are layout in a grid format in the texture, you could easily replace the texture by a new one which contains different sprites or even write into the existing texture the new sprites you got from www.texture. Again as long as the layout / location of the sprites doesn't change, the data (information) part of the Sprite Asset remains valid.
     
  23. kbm

    kbm

    Joined:
    Aug 7, 2014
    Posts:
    72
    Wow! This looks like everything I every wanted and then some! :D Awesome!
    Can you give us a rough estimate about when this will ship? I would use it right away! :)
     
  24. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Support for Inline Graphics is already in the current release of TextMesh Pro on the Asset Store (Unity 5 version) and in the Unity 4.6 release which is available on the TMP user forum.

    Support for Multiple Fonts & Material is what I am currently working on which I would like to release before or shortly after Unite in Boston.
     
  25. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    As requested, I added support for UTF 32. In the next release, you will be able to create Font Assets that contains glyph / icons in the UTF 32 range.

    You will be able to access these by using the uppercase U as follows "\U0001F3A3" in the Text Input Box. Via scripting, C# already supports this format so string s = "\U0001F3A3"; will work. See the example below.

    upload_2015-9-1_1-5-10.png

    In this example you can also see that I am using the new font tag to use a different font for the text since this Font Asset containing icons like the fish didn't include any letters.

    P.S. Again, you can now access UTF-16 glyphs by using \u00AE (lowercase u) and UTF-32 by using \U0001F3A3 (uppercase U). This works in the Text Input Box as well as in strings.
     
  26. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,598
    We have an issue on iOS with Unity 5.1.2 and the latest beta build from the forum. It even happens in a fresh start in the Editor, and the issue goes away as soon as we select a TextMeshProUGUI in the scene. However, as soon as we reopen the editor, it's back.

    We don't have this issue with an older project. Even the font supplied as sample show the same issue on devices.

    In short... are we doing something wrong?
     
    Last edited: Sep 2, 2015
  27. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    You might want to tell me what the issue is :)

    Please make a post on the TextMesh Pro user forum in the Feedback section and provide as much detail as possible on the issue. Include images showing the issue (before and after). Be sure to include images of the inspector showing the RectTransform values, inspector panel of the TextMesh Pro object as well as the material inspector with the Debug panel expanded. Provide information as well about your scene hierarchy and what other components might be affecting the text object. Layout Components and UI.Mask for instance.

    Since you haven't described the issue yet, I am requesting a broad range of things. With more information, we'll figure out what's going on :)
     
  28. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,598
    Oups! Edited by post and deleted the wrong info... The text appear as grayish squares.

    I'll head towards your forum. Screenshot of the issue in the current project might not be possible because of NDA.
     
  29. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    I see multiple .dll's in the plugins folder, is the source of these dll's included?
     
  30. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Just in case people run into this. When using the Canvas system, there is a bug in Unity were the Shader builtin variable _ScreenParam doesn't get set to the correct camera. In fact it always gets set to the camera with the highest depth regardless of whether or not this camera is rendering the text. This built-in variable is suppose to contain the resolution of the screen. So if set incorrectly or if you have no Camera in the scene because you are using a Canvas in ScreenSpace Overlay, then the shaders are not getting the correct value which will result in the text not rendering correctly.

    Unity has acknowledged this bug so we just have to wait for them to fix it.
     
    hopeful likes this.
  31. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The source code for those dll is not included. This is a native C++ plugin used by the Font Asset Creator which is an Editor Only component (excluded from builds) to create the Font Assets.

    This plugin consists of the TMPro_Plugin.dll (Windows) and TMPro_Plugin.dylib (.bundle in Unity 5) (OSX) and vcomp120.dll which is required for multi threading.

    I have provided the source code for this plugin to a few companies as part of a license deal. I can certainly provide the source code to the plugin if that is an issue in terms of licensing the product.
     
    silentneedle likes this.
  32. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Editor only dll's are no problem for our client. Going to buy your asset soon, thanks.
     
    Stephan-B likes this.
  33. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Here is a preview of added support for the new 2D RectMask that will be available in Unity 5.2.

    Please note that both Hard & Soft Masking is supported in TextMesh Pro with the 2D RectMask.

     
  34. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,166
    Edit: Woops, saw in the forums that there is already a 5.2 beta, never mind :p
     
  35. arcdragon1

    arcdragon1

    Joined:
    Oct 15, 2012
    Posts:
    118
    Hi, team.
    I updated my unity 5.2 from 5.1. and TextMesh Pro said the following error message.

    Assets/TextMesh Pro/Scripts/InlineGraphic.cs(77,18): error CS0619: `UnityEngine.UI.Graphic.OnFillVBO(System.Collections.Generic.List<UnityEngine.UIVertex>)' is obsolete: `Use OnPopulateMesh instead.'

    Cloud you help me?
     
  36. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    As per the post right before yours, there is already a release of TextMesh Pro for Unity 5.2 available on the TextMesh Pro user forum.
     
  37. arcdragon1

    arcdragon1

    Joined:
    Oct 15, 2012
    Posts:
    118
    Oh! very thank you! I'll get this!
     
  38. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    You are welcome :)
     
  39. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    New release of TextMesh Pro for Unity 5.2 is available on the TextMesh Pro user forum.

    This release include a few new feature but was released to mostly address the OpenGL ES 2.0 & 3.0 rendering issue introduced in Unity 5.2.
     
  40. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    As part of the Multi Font & Material support which I am adding in TextMesh Pro, it will now also be possible to define Font Assets to be used as Fallback in the event certain characters (glyphs) are missing from the currently assigned font asset.

    The list of Font Assets and order in which they will be searched will be defined by simply adding those Font Asset to the Fallback list in the TMP Settings file.

    Here is an example where the Impact SDF Font Asset is missing the "1/4" glyph (UTF16 Unicode) as well as an image in the UTF32 Unicode range. In this case, two different font assets are used as Fallback.

    upload_2015-9-14_0-37-4.png
     
  41. Irina-uk

    Irina-uk

    Joined:
    Feb 14, 2014
    Posts:
    28
    Please help, I have in the units Text Mesh Pro is not working the Extra Setting option ->Order for example 1 set after launching the project, reset the parameter to 0, the text appears again.

    It works when the script calls GetComponent <TextMeshPro> () .sortingOrder = 1 when he points to the editor, a parameter reset
     
  42. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    What version of TextMeshPro are you using?

    I'll check on my end to make sure this is behaving correctly while I await your reply.
     
  43. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    509
    Hi, is there a setting to change character widths and heights for a font like in Photoshop?

    I see in your Text Auto-Sizing Width Adjustment video that it is possible to change character widths based on text box size, but what about a setting just to change the overall width and height of characters in a font? Is it in the material - debug settings (scale x and y)?
     
  44. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The width and height of a font (characters) is set by whoever designed the font. So the only way to affect the width or height is to distort the font by changing scaling which is kind of what the auto width does on a character basis in the auto size settings.

    In the sprite asset editor panel, I do provide the ability to adjust the scale of individual sprites but that is proportional scaling for both width and height. I guess something similar could be added to the font asset editor. Please note that scaling of the font is being added as part of the support for Multi Font & Material support to enabled normalizing fonts so they match with each other.

    See the following video about this.
     
  45. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    507
    Hi,

    I have everywhere this warning :

    Converting from using anchor and lineLength properties to Text Container.


    And this error :

    UnassignedReferenceException: The variable m_renderer of TextMeshPro has not been assigned.
    You probably need to assign the m_renderer variable of the TextMeshPro script in the inspector.


    What can I do ?

    Thanks !
     
  46. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The converting message is because you upgraded from the older version which was using the length property instead instead of the Text Container and since whatever object is issuing this message hasn't been re-saved you keep getting this message.

    In terms of the error, I would need more information since that can be the result of many things. If you could please post the full error message and provide information as the how / when you are getting this error. I also need to know which version of TextMesh Pro that you are using.

    It is best to post all this information on the TextMesh Pro User Forum.
     
  47. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    507
    I handle the error, so it's ok.

    The full message of this warning :

    Converting from using anchor and lineLength properties to Text Container.
    UnityEngine.Debug:LogWarning(Object)
    TMPro.TextContainer:Awake() (at Assets/TextMesh Pro/Scripts/TextContainer.cs:151)
    UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
    PathologicalGames.InstanceHandler:InstantiatePrefab(GameObject, Vector3, Quaternion) (at Assets/Plugins/PathologicalGames/PoolManager/PoolManager.cs:75)
    PathologicalGames.SpawnPool:InstantiatePrefab(GameObject, Vector3, Quaternion) (at Assets/Plugins/PathologicalGames/PoolManager/SpawnPool.cs:249)
    PathologicalGames.PrefabPool:SpawnNew(Vector3, Quaternion) (at Assets/Plugins/PathologicalGames/PoolManager/SpawnPool.cs:1784)
    PathologicalGames.PrefabPool:SpawnNew() (at Assets/Plugins/PathologicalGames/PoolManager/SpawnPool.cs:1760)
    PathologicalGames.<PreloadOverTime>c__IteratorF:MoveNext() (at Assets/Plugins/PathologicalGames/PoolManager/SpawnPool.cs:1994)


    It appears each time time I spawned the gamepbject with the TextMeshPro (I'm using PoolManager from Path O Logicial).

    Maybe it's because I put a height and a width in the container to 0 ...
     
  48. Irina-uk

    Irina-uk

    Joined:
    Feb 14, 2014
    Posts:
    28
    Hello! It stared video

    TextMesh Pro - Animating Vertex Positions
    и
    Text Mesh Pro - Text Reveal Effect




    But it has not been able to find a package or scripts charactercolorizer.cs this VertexAttributeModifier.cs, so that these effects are realized. Prompt, the scripts are distributed in a separate package, or it is just an example, that you want to implement on their own.
     
  49. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    That script is located on the TextMesh Pro User forum in the following thread. You will need to register to the TextMesh Pro user forum to access this script.
     
  50. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    507
    Hi,

    I really don't understand why you don't update the asset on the asset store and we need to check regularly the official forum.

    Thanks
     
Thread Status:
Not open for further replies.
unityunity