Author Topic: Addition of a <material> tag  (Read 3488 times)

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Addition of a <material> tag
« on: July 15, 2016, 07:30:19 PM »
I am creating this post to make it easier to track this user request from another thread. This way, the conversation can remain focused on this topic.

I already went ahead and added a new <material="name of material">, </material> and <material="default"> tags. However, there are potential use issues with this tag which could lead to confusion so I am not fully sold on this tag.

First let take a look at a simple example where this works as expected. Using the following raw text, "A <material="ARIAL SDF - Yellow">simple</material> example."



In the example above, since we never switched font asset, we get the expected results.

Now if we were to reference a material that was not derived from ARIAL SDF, then the raw tag would show up as something like <material="IMPACT SDF - Outline">. Understanding why the tag would be visible in this case, isn't so bad given it is clear we are referencing IMPACT SDF when using ARIAL SDF. This should not be too confusing to users.

However, when you start to mix different fonts, it gets more complicated. Given the following raw text, "Example <material="ARIAL SDF - Yellow">using <font="IMPACT SDF">the </font>material </material>tag."



We get the expected results but that is because we took care of using </font> before trying to use </material> however, had we forgotten to use </font> before, the text on screen would have displayed as



simply because when </material> is encountered, we are still using IMPACT SDF and since the font atlas texture of the current material "IMPACT SDF" doesn't match that of whatever </material> is tracking which is "ARIAL SDF", the tag returns false.

Just to help understand what's going on behind the scene. Material Presets include a reference to the font atlas texture from which they were derived from. So Material Presets can only be used with matching font assets. Trying to use the <material> tag on a non matching material will result in the <material> tag returning false and showing up in the rendered text. This can be potentially confusing to users.

By contrast when being required to use the <font="name of font" material="name of material"> format, where the font and material are referenced together, these are always kept in sync.

Basically, I realize having a material tag would result in less typing but I think it could be confusing and result in support requests asking why this isn't working.

Let me know what you think.

cnumber1

  • Newbie
  • *
  • Posts: 11
Re: Addition of a <material> tag
« Reply #1 on: July 18, 2016, 09:48:51 AM »
Personally I think the confusion should be minimal, and perhaps there could be a detection of the failure to use the closing tags properly and either spit out some kind of debug waring/error and/or add something to the text itself so that it reads - "Example using the material </material>[derp - missing font tag...]tag."  or something to that effect :)

Perhaps I am not fully aware of what is going on behind the scenes, but if I had a word in which i used the font and material tag for each letter, would that no be sub optimal compared to just a material tag?

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Addition of a <material> tag
« Reply #2 on: July 18, 2016, 12:39:21 PM »
Personally I think the confusion should be minimal, and perhaps there could be a detection of the failure to use the closing tags properly and either spit out some kind of debug waring/error and/or add something to the text itself so that it reads - "Example using the material </material>[derp - missing font tag...]tag."  or something to that effect :)

Perhaps I am not fully aware of what is going on behind the scenes, but if I had a word in which i used the font and material tag for each letter, would that no be sub optimal compared to just a material tag?

Using <font="ARIAL SDF" material="ARIAL SDF - Preset 1"> or <material="ARIAL SDF - Preset 1"> is the same thing. In both cases, the ARIAL SDF font asset is used in conjunction with the Preset 1.

Using a different font per letter would result in extra draw calls. Using the same font but referencing different material presets of that font is (1) draw call. The material presets are always referencing the font atlas texture.

I suggest you review the video about Material Presets as this concept is pretty important in TextMesh Pro. https://www.youtube.com/watch?v=d2MARbDNeaA

cnumber1

  • Newbie
  • *
  • Posts: 11
Re: Addition of a <material> tag
« Reply #3 on: July 19, 2016, 10:14:05 AM »
That is what I thought. If it's the same under the hood to call font and material as it would be to just call material, then the material only tag is probably not necessary.

I was mostly concerned with a possible performance issue.

I am calling a new material (same font) for each character. I am adding "shinies" to the letters via shader effects and extra textures.

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Addition of a <material> tag
« Reply #4 on: July 19, 2016, 12:17:15 PM »
That is what I thought. If it's the same under the hood to call font and material as it would be to just call material, then the material only tag is probably not necessary.

I was mostly concerned with a possible performance issue.

I am calling a new material (same font) for each character. I am adding "shinies" to the letters via shader effects and extra textures.

How different are each of those FX on the letters? Depending on what those "FX" are, it could be more efficient to animate the light angle property of the material or to use an ENV Map like I did in the Frozen example video. https://www.youtube.com/watch?v=JMH1pN64GfI or like in this example https://www.youtube.com/watch?v=2wNnGNkGIrY

cnumber1

  • Newbie
  • *
  • Posts: 11
Re: Addition of a <material> tag
« Reply #5 on: July 19, 2016, 05:22:25 PM »
It's custom work out of photoshop.
We are using the TMPro gradients and colors, but there are several layered effects we are pulling in via textures made in photoshop.


Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Addition of a <material> tag
« Reply #6 on: July 19, 2016, 10:48:18 PM »
It's custom work out of photoshop.
We are using the TMPro gradients and colors, but there are several layered effects we are pulling in via textures made in photoshop.

Can you provide an example of the FX that you are wanting to do? It is always helpful to see those as it might give me some idea on alternative ways this could be handled.

cnumber1

  • Newbie
  • *
  • Posts: 11
Re: Addition of a <material> tag
« Reply #7 on: July 20, 2016, 10:29:50 AM »
We are using a lot of photoshops bevels, glows, lightings, and emboss type effects.
The issue is with lighting there are basic calcs to achieve nice lighting effects, but PS has an entire "warping" library that takes the lighting to the extreme, IE a simple light affects the base image, the outline, the glow, the bevel, the emboss, everything basically...

I would not expect you to reverse engineer PS, LOL, that would make TMPro cost like 1500$

Basically we throw together several effects in an "overlay" image that goes over the top of each letter.

Also at the shader level I was able to apply a technique that allows for an outline to encompass a word vs characters.
typically in PS when you give characters an outline and then "squeeze" the letters closer together the outline morphs to the outside of the "word" like this

[ Guests cannot view attachments ]

normally you wouldn't see the merge in the MPLE there..

normal -

[ Guests cannot view attachments ]

Basically the shader is a 2 pass, utilizing the grabpass and subtracting w/e is in the grab from the outline.
« Last Edit: July 20, 2016, 01:08:44 PM by cnumber1 »

cnumber1

  • Newbie
  • *
  • Posts: 11
Re: Addition of a <material> tag
« Reply #8 on: July 20, 2016, 10:40:44 AM »
Oh this reminds me, i gave myself public access to the submeshes in TMPro_Private.cs via a getter.
That may be something to consider adding to TMPro in general, I am using it to access their materials to do a fade in/out
« Last Edit: July 20, 2016, 12:57:31 PM by cnumber1 »