TextMesh Pro - Advanced Text Rendering for Unity - Beta now available in Asset Store

** Please post TextMesh Pro related questions in the Unity UI & TextMesh Pro section of the user forum. Be sure to add the TextMeshPro prefix to these posts.

UPDATE The first public beta of TextMesh Pro is now available on the Asset Store :slight_smile:

Here is a link to the new Asset Store Forum Thread.

Should you have any questions about the functionality / features of TMPro, please feel free to ask in this thread. For assistance, please visit the TMPro User Forum where you can request help as well as find instructional videos which should help you get started familiarized with TextMesh Pro.

IMPORTANT NOTE: The latest beta releases of TextMesh Pro with support for Unity 4.6 and the new UI as well as beta releases for Unity 5.0 are available to all registered users of the product on the TextMesh Pro User Forum. Once your registration to the forum has been approved, you will find the latest beta releases in the “TMPro - Alpha & Beta Releases” section of the forum.

Hello Everyone!

Today I am pleased to make my first WIP post and to finally get to show fellow Unity users what I have been working on over the past few months. So without further ado, I now introduce you to:


Image from actual text as seen in the Unity Editor.1

Introduction
TextMesh Pro! is essentially an advanced version of Unity’s built-in TextMesh Component. It was designed to provide users with a more powerful and flexible solution while remaining easy to use and with improved performance.

Improved Text Formatting
Starting with a larger text input box to a more comprehensive list of Rich Text which include underline, superscript, subscript or size to dynamic character spacing or word wrapping as well as support for kerning, TextMesh Pro! has you covered.


Example showing superscript, subscript and center justification.1

Advanced Real-Time Font Rendering
Just like all other text rendering tools, TextMesh Pro works with standard bitmap font atlases. However, a lot of the power and flexibility of TextMesh Pro comes from the use of Signed Distance Field “SDF” font atlases. The combination of SDF based font rendering and a set of advanced custom shaders delivers substantial visual quality improvements over normal bitmap fonts while giving users amazing flexibility when it comes to font styling texturing.


“S” Letters shows some of the dynamic changes that can be applied to a single SDF font asset. With the exception of the first bitmap “S”, all visible text including the captions is an example of SDF based font rendering.1

An unlimited number of visual styles treatments are virtually possible from a single SDF Font Atlas and they look great at any size.


Close up - These two letters are using the same SDF Font Atlas. They are simply using two different materials.1

Font Asset Creator
Want to use some new TrueType or OpenType font but need to create a font atlas for it? Not a problem with TextMesh Pro!. Just import your font in Unity. Open the built-in Font Asset Creator and within 30 seconds your new font asset is ready.


Built-in Font Asset Creator. No need for any external tools. Can create normal bitmap font assets or SDF font assets.1

Intuitive User Interface
TextMesh Pro! features several custom inspectors editor panels. They were created to give users access to what they need while keeping things simple.


Shown TextMesh Pro!'s custom editor material inspector.1

Scripting Interface
Need to create or modify text objects via scripts? All of Unity’s components offer a scripting interface and so does TextMesh Pro! All of the relevant properties of TextMesh Pro! can be accessed via script.


Example of TextMesh Pro! object creation via script.


Here is a list of some of TextMesh Pro’s features.

TextMesh Pro! Main Features

  • Easy to use with simple UI featuring custom inspectors and editor panels.
  • Supports both Bitmap Signed Distance Field font atlases.
  • Built-in Bitmap SDF font atlas creation tool.
  • TrueType OpenType font support.
  • 2D Text objects can be created in the Editor or dynamically via scripts.
  • Better performance than Unity’s built-in TextMesh and No Alloc.

Formatting Styling Options

  • Dynamic font sizing. SDF font atlas renders sharp and great looking text at any sizes.
  • Rich Text support. Per character tags include color, bold, italic, underline, superscript, subscript, size, tab and position.
  • Text Anchoring - The usual 9 positions.
  • Text Alignment - Left, Center, Right and Justified.
  • Line character spacing.
  • Automatic word-wrapping.
  • Kerning.
  • Multiple Texturing Mapping options.

Built-in Custom Shaders

  • Basic Bitmap text shader
  • Face vertex color
  • Face Texturing with multiple mapping options
  • Basic SDF text shader
  • Face vertex color
  • Advanced SDF text shader
  • Face vertex color
  • Face texturing with multiple mapping options
  • Border texturing
  • Border thickness softness control
  • Beveling + Glow control
  • Advanced Surface SDF text shader
  • Real-time lighting shadow casting
  • Plus same features as Advanced SDF text shader

Final Note
Well! That is it for my first post. Obviously, I would love to get your feedback impressions of TextMesh Pro! thus far as well as answering any questions you may have.

I do plan on following up with additional example images videos to provide better insight on some of the features and operation of TextMesh Pro!

Thanks everyone :slight_smile:


*1 Images are of actual unedited screenshots taken from within Unity’s Editor.

3 Likes

Wow, this is awesome! Can’t wait to get my hands on this … and I’ll be sure to support it in ScoreFlash as renderer :slight_smile:

Thank you! I look forward to seeing TextMesh Pro! working with ScoreFlash.

Looks really cool, definitely something Unity could use! How much do you expect to charge for it? Also, how efficient is this and have you tested if this will run well on mobile?

Thanks :slight_smile:

I have not yet decided on a price.

TextMesh Pro! currently outperforms Unity’s TextMesh in the performance tests done thus far on desktop(s) and android devices. I am looking forward to testing it on iOS devices and am hopeful that we will perform nicely there as well.

Here is a video of a performance test I did a few months ago. This is using the Advanced SDF shader which is more complex than our Basic SDF shader. Be sure to watch in HD.

https://www.youtube.com/watch?v=tTqHhxYWdhY

Unity’s TextMesh vs. TextMesh Pro. This is a crazy amount of objects.

On the memory side, there is no allocation made per frame but I’ll give you a more detailed answer later today.

Here is a video I made last night going over the basics of the tool in the Unity Editor.

wow very good

Here are a few examples of the results I got from playing around with this font I downloaded.

After creating the SDF font asset for this font, I created a new game object to which I added a TextMesh Pro component. This image shows how this font looks without any treatments applied to it.

After making a few tweaks (adding a border + texture + bevel + glow) … this same plain font was transforms into this.

In order to get this new look, 3 new material we created from this original plain one. This final image is comprised of 3 TextMesh Pro objects, the Bevel + Red Glow, the Shadow and lastly the Blue Glow.

Here is an image of the Blue Glow material applied to this font.

Edited the text and made some tweaks to the bevel and glow.

If anyone is interested, here is a video showing the some of this process.

Lastly, here are a few more variations. Again keep in mind that all these different text objects / images are using a single 512 X 512 SDF font atlas that is only 256K in size and contains the full ASCII character set. The only difference between these objects are the dynamic material shader properties being different.

Nice!
Could you say anything about the time frame?
Days, weeks, months?

I would love to release TextMesh Pro! within the next 30 days but it all depends on getting enough feedback. I really want to make sure it includes the majority of the features that potential users would want.

So far, the feedback is slow to come. I really don’t know if that is typical or if the title of the post needs to be changed or maybe few care about a more powerful alternative to Unity’s built-in TextMesh component.

Some things I’d be interested in seeing (forgive me if you already have these solved):

  1. an interface for numbers and text without allocations:

Funcname("Some text “, anInt, " some more text.”); << a common thing in games is to mix text with numbers. Now as the data is supplied separately, your function is able to generate the required text without any string manipulation, that is you should only have to read the string. Currently, this is still left to the programmer to take care of, and it would be nice if middleware took care of it.

People typically go: Funcname("sometext "+someInt.ToString()); or such - which obviously means a new string is built and garbage is allocated. By having a method which accepts numbers as something you can parse, we can probably avoid the allocations.

  1. Distance field font rendering support in your atlas code plus perhaps a shader for it - this means the font does not require huge amounts of ram to look good, and generally looks good at any size. (example: http://forum.unity3d.com/threads/61243-Unity-Signed-DIstance-Field-Textures)

  2. Various functions for getting the sizes of things in world and pixel space. I think these would be useful to people for game related purposes.

  3. For very large font atlases (asian for example) you might consider packing the font into R, G, B, A separately and using a shader to split them to save atlas space - a useful thing not only for large char sets, but for mobiles seeking to save ram with larger font sizes.

Bear in mind I might not necessarily be a prospective customer, I’m just pointing out what I’d expect from a standalone middleware solution.

I wouldn’t worry too much about that … personally, all I need is that the text looks awesome and that I can easily check width / height and control width / height if I need to (that’s stuff I need for the ScoreFlash integration). Personally, I like it when things are simply. Too many features often just make things feel bloated :wink:

There’s a solution built-in to the .NET framework which Unity uses (well, technically it uses Mono - but that really is .NET):

string.Format(“Some text {0} and some more {1}”, someIntIfYouWish, anyOtherObjectYouLike);

Doesn’t that allocate a new string though? …googling now…

edit: yeah it generates garbage. My most was about manually parsing the strings and ints in code to output uv coordinates for the quads. By only growing as needed and not shrinking, the garbage should drop to zero. I do this myself for scores that change often but was thinking middleware could too. Scores are ints so it’s easy to knock off bits then compare.

Text can be provided as either a string or char[ ]. The string is parsed and converted into a char[ ] since internally the process works on char[ ]. Currently when updating a text object each frame, GC Alloc is zero. However, whatever small script is feeding that .text (string) is inviting that GC monster. So in terms of providing a function to enable users to easily take their data to turn it into a char[ ] and avoid string manipulation, I’ll give it some thought.

I certainly agree that Signed Distance Field font rendering is awesome. On the other hand, I am not sure I understand your point given that every single example in my previous posts are using SDF font atlases created with the TextMesh Pro’s built-in Font Atlas Creator and using one of the included custom SDF shaders.

Signed Distance Field font rendering is pretty amazing which is why TextMesh Pro! was designed to fully leverage that power and flexibility.


Example of changing some of the SDF Shader properties via script. Text shown is using the same SDF font atlas as the RED Zone examples in previous posts. This is just a different material with different shader properties.

The mesh / text object creation process currently results in a struct that contains key information about each characters part of the mesh. Such information could be used to further manipulate the mesh / layout or enable editing of the text in the camera view, etc…

Do you have anything specific in mind?

In terms of your last point, let me get back to you on that one if I may.

Here is a screenshot of the Unity Editor showing the properties of TextMesh Pro’s Advanced Text shader that can be changed either in the editor or via script.

In the case of this glow effect, this little script is simply changing the value of the Glow Power in a Coroutine. The script can be seen in this image as well. Note that animating most of these properties does not cause the text object / mesh to be redrawn and is therefore very efficient.

All of the techniqu named materials use / reference the same techniqu SDF font asset which contains the atlas and font data. By applying the Metal Red + Glow material to this text object, it would instantly make it look like one of the RED ZONE examples.

I can only speak for my self but as someone coming from a Flash background I have missed these features so much in Unity.
I remember wondering how Unity could have such unintuitive and sub par font/text features when I made the jump.

In my latest game I have already had to redo the bitmap fonts like five times since I wanted to tweak the look, change font size, missed a glyph/character…

From what you have shown I could have saved hours if not days of work.

And if your solution looks better and Performs better it’s a no brainer.

Sorry about the SDF suggestion that you already supported - flew over my head late at night! It gave you more room to demonstrate to customers though :slight_smile:

Onto SDF’s shader - on PowerVR chipsets, alphaTest is the devil and will slow it down quite a bit. An alternative mobile shader might be developed that uses step instead - which is (for reasons I don’t know) faster than clip and alpha test - just a thought if you wanted to see if was possible to avoid using alpha test for iOS / other PVR chipsets.

1 Like

If this was released, I would pick it up in a heart beat. Would literally be what I am looking for.

To pragmatically set 3d text, especially on a gameobject. Would make things super nice.

I’m not sure what you mean by using ‘step’ instead of ‘clip’. (I’m very curious actually :slight_smile:
but let me write a little on this subject, even so I haven’t done extensive testing on all architectures.

First, alpha testing is not used. So we can focus on the potential use of discard() (a.k.a texkill(), clip(), …)

TextMesh Pro current set of surface/fragment shaders uses alpha blending with ZWrite off (executed in unity transparent pass), so the underlying HW doesn’t take into account this geometry in any Z buffer based visibility operation.
This is normally the core of the problems (doing per pixel conditional depth writes), especially on PVR architectures. (as you hinted)

Now on using discard() to early out when you know your shader will produce nothing ( potentially saving computation bandwidth.)
I found that on the desktop its always a win on nvidia HW, but does come with overhead even on modern AMD GPU.
Because of this, its preferable not to use discard() when the majority of the pixel will be written. And this is the case when rendering small fonts.

With alpha blending there is another hint that the HW receives to optimize the operation since a shaders will return 0 for fully transparent pixel,
causing the raster blend operation to essentially be a NOP.
From this, the HW has the opportunity to skip the ROP altogether, potentially saving on bandwidth.

All in all, early out alpha blending is an area worth investigating further to gather definitive data.

1 Like