Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Text Mesh Pro Draw calls

Discussion in 'UGUI & TextMesh Pro' started by narger, Dec 20, 2017.

  1. narger

    narger

    Joined:
    Dec 2, 2014
    Posts:
    51
    Hello, i’m new in the Text Mesh Pro world, so this may appear as a stupid question.

    I was wondering if different fonts can be ‘packed’ into one, so we can have only one draw call (just like we can do with sprites).


    I’m asking it beacuse draw calls in mobile development are a critical value to anaylze.


    Thank you in advance
     
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    How about you use it and find out?

    Also: draw calls aren't the demon you're thinking they are :) saving 10 is utterly pointless but saving 1000 is a big deal.
     
  3. narger

    narger

    Joined:
    Dec 2, 2014
    Posts:
    51
    I tried, otherwise i wouldn't have asked here :p

    By the way, in my case draw calls are THE demon, since i need my game to run at 60fps; i mustn't have more than 10 draw calls in order to do it.

    Isn't there a trick to do it?

    Sorry for bad english :p
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Nonsense.

    If 10 draw calls is the margin you have far bigger problems and it won't ever be consistent even on the same phone type across different people. Some people may have texts or whatever. 10 draw calls is a bad joke.

    I assume you're deploying to mobile.
     
  5. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    As @hippocoder stated, draw calls used to be a major thing back in the days of iPhone 3 or thereabouts.

    In today's market and on most devices, there is no real discernible performance difference between 1 or a dozen draw calls.

    As such the added complexity of trying to combine these glyph into a single atlas where we might run into issues trying to fit all the glyphs into a single texture or having to use a larger texture which might not be possible due to limitations on texture size on mobile devices or the added performance impact of using a larger texture which could completely negate the performance gains which would already be negligible.

    Soi just like @hippocoder said, unless you are looking at a reduction of over 100 draw calls, it isn't really worth the trouble.
     
  6. narger

    narger

    Joined:
    Dec 2, 2014
    Posts:
    51
    My target is iOS/Android devices, since I have ten fonts, and two sprite atlases i have 12 draw calls, but i noticed that on a 1080p screen it goes from 47 to 55 fps (HTC One M8s), i wanted to have my game as smooth as possible on every device, and reducing draw calls seemed to help a lot (i used to have 20 draw calls and the game was so laggy at 20/30 fps)

    If you can provide me help in that way, i'll appreciate it a lot :D

    P.S. I wouldn't ask it if it wouldn't have performance impacts
     
  7. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It doesn't have impact. It's not the draw call causing it, it's the shader / fill rate.
    Everything you think you know is likely wrong / out of date info...

    Can you tell us what shaders you are using and are you using profiling?
     
  8. narger

    narger

    Joined:
    Dec 2, 2014
    Posts:
    51
    I'm using:

    Sprites-Default shader for sprites,

    TextMeshPro/Mobile/DistanceField for texts.

    I arrived to the conclusion of draw calls affecting fps by doing a lot of experiments, but if you can tell me a way that can increase my game' speed using at the same time texts would be brilliant ;D

    This is my profiler:

    profiler.png

    Thank you

    P.S. Scripts are optimited, there is only one of them that needs to run plenty of code but im gonna fix it soon
     
  9. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Are these text objects static or are they getting updated every single frame?

    Also please set the Profiler to Deep Profile and expand the Camera.Render.Culling.Camera.FireOnPreCull().. until you can see the TextMeshPro_OnPreRenderObject() and provide an image of what is shown there.
     
  10. narger

    narger

    Joined:
    Dec 2, 2014
    Posts:
    51
    Ok, here is it:

    profiler12.png

    In my scene i've got 5 different TMPro objects with 5 different fonts, all the rest is composed by 3 sprite atlases

    P.S. I'm not using 'static' flag on these objects
     
    Last edited: Dec 23, 2017
  11. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    By static I meant whether or not the text objects are being changed each frame.

    Can you please show an Expanded TextMeshPro.GenerateTextMesh()?
     
  12. narger

    narger

    Joined:
    Dec 2, 2014
    Posts:
    51
    Sorry for late, I was busy with Christmas holidays :p

    BTW, here is an expanded TMPro.GenerateTextMesh() :

    new.png

    And no, i dont update texts every frame (except the FPS meter ... )
    Thank you

    EDIT: Ok, it was the FPS meter! Thank you all!

    So, going back to the previous question, are you sure that we can't combine TextMeshes into a single draw call? (Having multiple ones implies lot of context switch)
     
    Last edited: Dec 29, 2017