Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Alright, I'll come back to you as soon the next release hits the store :p
     
  2. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    You are keeping me busy but I do like those feature requests :)
     
  3. Enoch

    Enoch

    Joined:
    Mar 19, 2013
    Posts:
    198
    Fantastic asset, well done and congratulations.

    I just bought your asset and I have a couple of questions.

    First is there any way, now or sometime in the future, to be able to programatically convert a .ttf to a useable asset that TextMesh Pro can then immediately use at runtime? I'd love to be able to give users of my app the ability to upload and use there own fonts. It looks like you are using a seperate dll for that functionality and I am not sure if I can get that to work (I have had trouble using dll's in the past for certain targets).

    Second when using Distance field I lose 3D depth with other none text objects (I assume that this is because you are doing your own z-buffer/depth field calculations, I haven't looked to deeply at the shader yet though). When using the Distance field (surface) I get my z buffer back but not with other TextMesh Pro objects. I can control depth through sorting layer Id and sorting order (this is awesome thanks for this) but it still isn't Ideal, I still need to calculate sort order based on camera depth every X frame if I have a lot of objects moving about. Is there some reason (I am sure there is) I can't use z-buffer, is this related to unitys problems with transparent objects and z order?

    I have determined that if I back the TMPro object with a regular 3d object it gets rid of the issue since the regular object will obscure all other TMpro objects based on z buffer. So maybe this is my best case solution.

    Lastly (sorry for the long list), I will need to eventually have greater control over the UV coordinates. Is there any way to give per texture control of tiling and offset for textures at the shader level (similar to other shader controls)? I believe giving us control this way shouldn't break any of the other UV mapping options (I still want them to work like the do) I just want to be able to zoom and move around my texture in this context.

    Again great job, keep up the good work.
     
    Last edited: Jul 28, 2014
  4. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Thanks!

    Unfortunately, the dll was designed to be used in the editor to allow creation of assets (offline) but not at run-time. I have requested from Unity some changes to their font system api which (if / when we get those), would make it possible to generate font assets at run-time. Please note the generating a signed distance field asset from the ttf can be performance intensive so that might also be an issue for run-time use. (We will cross that bridge when we get there I guess)

    Do you have an example of the sorting issues you are running into? Take a look at the Floating Text example in the TextMesh Pro package, all those objects should be sorted correctly in the scene.

    Some Notes:
    Transparent objects require depth sorting which Unity handles behind the scene. However, this is based on the center of the object. Depending on the width / orientation of some objects this could produce wrong results.

    Changing sorting layers (affects the render queue) which can mess things up with in terms of sorting.

    Again, give me a few examples so I can take a closer look at this.

    UV2 is current used to encode information which the shader needs which is why tiling and normal options are not available there. Now in Unity 5.0, Unity has added UV3 and UV4 which will make it possible to enable tiling again.

    Thank you and I will. Please help me promote TextMesh Pro and spread the word to other Unity users :)
     
  5. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    269
    So I had another question, I found out how to get the bounds of a particular textmeshpro object or even a specific line, but is it possible to get the baseline position for a line? I'm trying to position a 'click to continue' animation at the end of a line of text, but the y position is a bit tricky because it shifts depending on the inclusion of characters that dip below the baseline of the text..
     
  6. Enoch

    Enoch

    Joined:
    Mar 19, 2013
    Posts:
    198
    Thanks for the quick reply, very professional. I am impressed.
    Just curious, is there a reason you didn't include source for this functionality? I am just curious if this part of functionality will always be closed source to us. I'd love to see what your doing in there. It's not ideal but I will understand if there are proprietary reasons. If it's 3rd party perhaps there is a way to get source from them, etc.
    Ok so I did some more testing. I was creating my asset with a render mode of Hinted smooth or raster. When I used the Distance Field, the Distance field shader worked just fine (this of course should of been obvious but I am still playing with options).

    Distance field is now sorting wonderfully. Distance Field (surface) however still doesn't sort correctly. For instance create two TextMesh Pro objects A and B, place B above A use the default ARIAL SDF asset for both. Change the Arial ADF shader to Distance Field (surface), this should effect them both. B will not correctly overlap A with this shader. If you put a plane in between them B will properly be above the plane and A below it.


    I was looking at the shader and I may play with this further and modify it. But I think all I need to do is provide shader UV _TilingUV2 and _OffsetUV2 Vector2 variables and then modify the input.uv2_FaceTex before its ever used in the PixShader. So for instance in TMPro_Surface.cginc you have:
    Code (csharp):
    1.  
    2. faceColor *= tex2D(_FaceTex, input.uv2_FaceTex);
    3. outlineColor *= tex2D(_OutlineTex, input.uv2_FaceTex);
    4.  
    I might do somethin like:
    Code (csharp):
    1.  
    2. float2 inuv = input.uv2_FaceTex*_TilingUV2+_OffsetUV2*_TilingUV2;
    3. faceColor *= tex2D(_FaceTex, inuv);
    4. outlineColor *= tex2D(_OutlineTex, inuv);
    5.  
    I will test it out let you know. If you have a more permanent solution that doesn't break upgrade path I would prefer that of course.

    Will do, thanks for you effort.
     
  7. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    TextMeshPro.textInfo.characterInfo[] holds information about each character in the text object. This includes bottomLeft, topRight, Ascender (topLine), Descender (bottomLine) and baseline (which is what you are looking for).
     
  8. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    This dll & dylib are native C++ plugins which also use other C++ libraries. They have to be compiled separately for the PC and MAC. They are not C# .net dll's.

    The hinted raster modes (i.e. non distance field modes) are to be used to generate bitmap font assets using the TextMesh Pro bitmap shader.

    The Signed Distance Field modes (16 or 32) are to create Signed distance field assets using our SDF Shaders. Although you could use the SDF shader to render a bitmap texture, it would be wrong and not look good.


    Signed Distance Field shaders or bitmap shaders have no real impact on sorting order. When using Sorting Layers, the Render Queue is changed in the shader (material) which is why your Arial SDF (may) appear to not sort correctly.

    Run the Floating Text example scene and let me know if the sorting order is correct. This scene uses the Arial SDF and I suspect it won't sort correctly (but it should). Once we can confirm the behavior you are having, I can guide you through the process to fixing the sorting issues you might be experiencing.

    Scaling information is being encoded in the UV2 stream which is why we had to limit the tiling as we don't have enough precision to encode both the uv info and the scale in UV2. Why are we encoding data in UV2? This enabled us to lower the shader requirement to shader model 2.0 as opposed to using derivatives which require shader model 3.0. This is temporary as Unity 5.0 will include more vertex streams which will enable us to use other streams to pass this information to the shaders.

    I hope this makes sense.

    P.S Sorry about the delay in replies today. I was on a flight from the West Coast to East Coast all day. From 3:00 AM PST to 10PM EST. It was a long day...
     
  9. sschaem

    sschaem

    Joined:
    Feb 14, 2014
    Posts:
    148
    If you add this logic to the UV generation, preferably do it in the vertex shader.
     
  10. Enoch

    Enoch

    Joined:
    Mar 19, 2013
    Posts:
    198
    I am still messing around with this I will get back to you with more info.

    This is interesting. I didn't realize what you were doing until after I just went ahead and implemented tiling and offseting anyway. First I did it in the shader but as sschaem mentioned I'd probably prefer this infomation in the UV2 since that won't break batching. So re-implemented it in GenerateTextMesh right after you modify UV2 information for the Texture Mapping Options. Even though you are packing this information and I know now that I am losing precision, I honestly didn't notice. I am curious at exactly how much percision we actually have available in UV2? I certainly never needed the full 32 bits in the first place, but its a float so I wasn't getting 32 decimal bits between 0 and 1 (I think its just 23). But even if we only ended up with 12 bits or 4096 distinct divisions that is still pixel accurate for 4096x4096 resolutions and I certainly am not using that.

    My point is that honestly there might be plenty of precision left even after you pack scale in there for most people. For my purposes it worked beautifully. I am using it to feed atlased image data into the face texture, and of course for atlases you need tile/scale and offset info. I'd still like to know precisely how much precision I have because I could then know how big my atlases could get before I start to notice precision loss. It looks like you take about half but I need to look at it a little bit more.

    Thanks.
     
  11. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    269
    Thanks, that did the trick! Took a bit to figure out what information was where, and what it was relative to, but I finally got it all down.
     
    Last edited: Jul 29, 2014
  12. Enoch

    Enoch

    Joined:
    Mar 19, 2013
    Posts:
    198
    Ok I did this and as suspected it did not sort correctly, this happens when I set the default Arial SDF font asset to use Distance Field (surface) for its shader. When I use Distance Field (not the surface one) then it sorts just fine. Note I am changing the default Arial SDF resource directly (using a different TMPro object), when I change the shader.
     
  13. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Glad to hear :)
     
  14. jluki

    jluki

    Joined:
    Aug 11, 2013
    Posts:
    24
    Hi,

    Is there a chance to get TextMesh Pro working inside Windows Store Apps?
     
  15. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    What issues are you running into?

    Check the following posts on the TextMesh Pro User Forum.
     
    Last edited: Jul 31, 2014
  16. jluki

    jluki

    Joined:
    Aug 11, 2013
    Posts:
    24
    I get an error during runtime that some serialization component expects more bytes than it really gets. the text mesh isn't shown at all.
     
  17. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Can you post the exact error message?
     
  18. jluki

    jluki

    Joined:
    Aug 11, 2013
    Posts:
    24
    Hi,
    the error massage is simply:

    A script behaviour has a different serialization layout when loading. (Read 220 Bytes but expected 312 Bytes)
    Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

    I've also posted a screenshot.

    What I did:

    1) Created empty Windows Store App for SDK 8.1
    2) Imported TextMesh Pro Asset
    3) Added a "TextMesh Pro Text" GameObject with default values ("Hello World!", Shader: TMPro/Mobile/Distance Field)
    4) Generated VS solution and started App in x86 Debug mode.
    5) Development Console presents the mentioned error

    Should TextMesh Pro work inside Windows Store Apps?
     

    Attached Files:

  19. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I doesn't say from which script or line #?
     
  20. jluki

    jluki

    Joined:
    Aug 11, 2013
    Posts:
    24
    No, the error message contains no more Information.
     
  21. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Do you get the same error in debug vs. non-debug on the Window's Store App?

    Are there any options in the build modes that could affect this? Like multi-threading option or something that would affect serialization?

    P.S. I am still away (out of the country) due to a family emergency so my resources are limited in terms of dev environment right now.
     
  22. jluki

    jluki

    Joined:
    Aug 11, 2013
    Posts:
    24
    Hi,

    At the moment I'm still prototyping some things. I will investigate your questions during the weekend and will give you feedback.

    I wish you all the best for your family emergency!
     
  23. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Thank you.

    Keep me posted on your progress. I should be back mid week and I'll dig into this to try to narrow it down. That's a pretty vague error to track on that Windows App Store
     
  24. jluki

    jluki

    Joined:
    Aug 11, 2013
    Posts:
    24
    Hi,

    I'm sorry but until now I couldn't find any useful information that could help you narrow down this problem. It's clear that it has something to do with serialization inside Unity - that happens through the inspectors; they serialize the data into the unity scene file(?) - and deserialization during runtime. I tried some modifications on the code - especially adding and removing SerializeField attributes - but it didn't help. I expected that at least the number of bytes changes, the error message presents. But it turns out to be always nearly the same amount of bytes missing during deserialization.

    Nevertheless serialization and Windows Store Apps seems to be a hard topic for its own. For me this is still a black box. But I'm wondering if you could reproduce this behavior on your machine.
     
  25. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I am going to be traveling all day today but I am finally heading home so I'll be able to take a closer look at this tomorrow.
     
  26. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Do you need to build atlas or can it be done at runtime for non english languages?
     
  27. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    You need to build the atlas using the included Font Asset Creator. You have full control over which characters to include and given SDF Font Assets are typically smaller than their bitmap counterparts, you can usually fit several 1,000's of characters in atlases. There are several posts in this thread or the WIP thread about this subject as well as on the TextMesh Pro User Forum.

    Here is a link to a video showing how I packed over 11,000 Korean characters in a font atlas.

    Back to Dynamic Font Atlas creation... The only place where it makes sense to do that is with CJK where you have no idea what characters might be used and the character set is too large to fit all characters in a 2048 X 2048 texture which is a limitation on many mobile devices. In such case, Dynamic font atlasing would make sense but there is a performance impact as characters need to be added to the texture at runtime whereas the static font atlas do not.

    I have been thinking about ways to support dynamic Signed Distance Field font atlasing which would have advantages over Unity's current dynamic font system. Such feature will have to come after the release of a few more features I have been working on like the Text Container, Run-Time Text Input and Multiple Font Assets uses in the same text object.
     
  28. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    TextMesh Pro User Forum & Support
    If you have purchased TextMesh Pro, please be sure to register to the TextMesh Pro User Forum and to visit the forum should you run into any issues. By now, most of the support issues that people are running into have been addressed on the forum and as a result you are most likely a few minutes away from a solution.

    If you don't find the answer to your issue on the TextMesh Pro User Forum, please make a post in the Support section as this will in turn benefit other users when a solution is provided.

    Don't get me wrong. I love answering your emails but I always feel bad when I can't get to an email for a few hours or just woke up to discover someone has been waiting for me to reply when the answer is on the forum and you could have been back up and running in minutes.

    In the end, feel free to use whatever method is most convenient to you to get your issues addressed. I am here to help and most importantly grateful to have you as a user of TextMesh Pro.
     
  29. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Unite 2014
    Just wanted to let you all know that I just committed to be a Bronze Sponsor at Unite 2014 in Seattle and will be showing TextMesh Pro in the exhibit area.

    If your going to Unite please drop by and it will be my pleasure to give you a personal demo and answer any of your questions in person.

    Now, If you already own TextMesh Pro then please stop by as I would love to personally thank you for using TextMesh Pro and being one of my customers :)
     
  30. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    One of Three videos submitted to Unite for Unite 14 in Seattle.

     
  31. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Version 0.1.45 is now available for the private Beta testers on the TextMesh Pro User Forum. Please make sure you register(ed), I can't remember if you did. Send me a private message and since you contributed to this release in terms of feature request, I can set you up to have access to that beta for testing before releasing it to the Asset Store.
     
  32. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    As I mentioned earlier, I'll be attending Unite in Seattle next week. I will be in the exhibit area with the other sponsors demoing and answering questions on TextMesh Pro. Please drop by if you will be at Unite.

    Here is an image of the banner (almost final version) to promote TextMesh Pro.

    upload_2014-8-16_16-10-19.png
     
  33. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Unite 14
    Just getting some demo content ready for Unite next week in Seattle.

    Here is a revised version of the "Amazing Quality" text used in the sign for the show.



    Now here is a close up of the text to fully appreciate the quality.


    This is using the TMPro - Distance Field Surface Shader which 3 lights (Orange / Blue Point light + Directional) + Textures on the Face and Outline.
     
  34. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    What did the text looked like prior to changing some of the TextMesh Pro material properties?



    This text (title) is just plain Impact font. I adjusted character spacing and tweaked the kerning a bit. You can still see the orange and blue point lights affecting the text but otherwise, this is just plain text. It is amazing how much of a difference adding a few textures, bevel and glow can make.

    Now just for fun, let's take a look at how this text using the same Impact font looks like using Unity's Text Mesh.

    upload_2014-8-17_20-48-8.png

    As you can see, Bitmap Text Rendering simply doesn't stand a chance against Signed Distance Field. When you factor in the improved text formatting options of TextMesh Pro and all the real-time visual tweaks we can do to the text and real-time lighting, comparing Text Mesh to TextMesh Pro is simply unfair.

    Too often, I am tempted to create crazy looking text using all the bells and whistles in TextMesh Pro but I tend to forget how much better just plain text in TextMesh Pro looks over the other Unity text options.
     
  35. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    269
    That banner looks pretty good, though funny enough I think the screenshot you used for 'dynamic text styling' shows quite a bit of aliasing. :p

    I'm making really good use of TextMeshPro on my project, I'm really happy to have picked it up. Thanks again for your hard work!
     
  36. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The image is a screenshot from within Adobe Illustrator so it doesn't display correctly but here is the original :)


    You are most welcome. :)
     
    Last edited: Aug 19, 2014
  37. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I see some dlls, not full source?
     
  38. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Everything that is C# / Unity code is included, The .dlls are for the Font Asset Creator which is a Native C++ plugin.
     
  39. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Can you post a link to that thread? I haven't been able to find that. If Text Mesh Pro can be used as a "drop in" replacement for UILabel, that sounds really interesting.
     
  40. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    If you search this thread, you will find a few references (like here for instance) of users using TextMesh Pro with NGUI. You can also visit the TextMesh Pro User Forum, where there are also a few threads referencing it being used with NGUI.
     
  41. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I read this entire thread and yeah, there are mentions of people getting to work without too many specifics. I searched the TextMesh Pro forum for "NGUI" and came up dry, other than some very specific (and kind of long) troubleshooting threads involving depth and scale issues. It'd be super useful to have some basic "here's how you do it" information. Otherwise, going on an R&D hunt isn't too appealing. I take it that it's more complex than being an easy replacement for UILabel in NGUI.
     
    Livealot likes this.
  42. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    269
    I've been using TextMesh Pro in combination with NGUI, so I suppose I can chime in. The component doesn't have any inherit issues that prevent you from using it as part of your NGUI user interface, and I found it worked well as a replacement for UILabel, though there are some caveats. First, you need to remember to set the TextMesh Pro object to orthographic mode to display text of the correct size. The TMP object sometimes conflicts in terms of draw order with NGUI objects if they share the z position, so you will need to make use of Sort Order settings in both NGUI and TMP to ensure proper render order. The TMP object also as you might imagine doesn't respond to certain NGUI controls such as the panel's alpha slider, so if you use or animate panel alpha you'll need to control the TMP objects alpha separately.

    If that doesn't sound like too big of a problem (and it's not for me), then otherwise the two play quite nicely together.
     
    Livealot likes this.
  43. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Oh, OK, that sounds alright. Thanks for the info!
     
  44. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Thanks Doddler for providing some good insight on this :)
     
  45. KindlyAssets

    KindlyAssets

    Joined:
    Jun 26, 2013
    Posts:
    4
    Hey All,

    Just wanted to drop a note to say that I saw Stephan's plugin being demo'd at Unite this year and it truly is exactly what you need in Text rendering. Really impressive, hits all of my pain points and makes the designers happy as you can have many variations using one font. The price point of $65 is nothing for what you get and well worth it.

    I'm in the process of converting one of our projects and so far it's been pretty painless.

    Good job Stephan and keep it up!
     
  46. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    Localization?

    I would like to hear the best approach to localize TMP, especially with right to left languages. It looks like the i2 localization plugin does a good job automating changes in NGUI to switch language between left to right and right to left, which probably just adjusts the alignment component of the UIlabel when it switches the text. And I think adding the NGUI localize script to the TMP object will work to change the text. But I'm not sure if that would also switch the alignment in TMP if I were to use i2.
     
  47. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I currently don't have support for Right to Left languages but that is something I will be looking into over the next few weeks.
     
  48. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Thank you :)
     
  49. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Gradients using Vertex Colors
    At the request of a few users, I added support for doing gradients using vertex colors. Since a Texture can be applied to the face and outline of the characters, these two things can now be combined to create some pretty weird gradients / patterns :)


    Gradient using Vertex Colors


    Editor Panel for Vertex Color Gradient
     
  50. KindlyAssets

    KindlyAssets

    Joined:
    Jun 26, 2013
    Posts:
    4
    Hi Stephan, looks great. What do you think about being able to specify the Outline color using vertex Colors? That way I can have different outline colors that all use the same material?
     
Thread Status:
Not open for further replies.