Drawcall and fps trouble

hi every one,i have a trouble with drawcall and fps.I have create atlas sprite for my game but it not really reduce drawcall and causing drop fps.Can you tell me how to optimize my game.it really lag.

Welcome @ndmh.

Can we get some more information? Are you testing on actual hardware or emulator or simulator. What platform are you testing on, iOS, Android, windows, etc?
How many draw calls are there? How many nodes are there? How big are the texture resolutions?

having an atlas sprite isn’t necessarily going to reduce the drawcalls. you may try to install spector.js, a chrome extension that will tell you how the drawcalls are executed, in a very visual and intuitive manner. from my observations, these common cases will affect the drawcall count (i assume every sprite mentioned below is belonging to the only one atlas you have):

  • mixing text with sprites. you have “sprite1”, “text label”, “sprite2” (in different nodes). this means 3 drawcalls;
  • mixing color modes (e.g. you change the color attribute of sprite node). you have “sprite with color 1” and “sprite with color 2”, this means 2 drawcalls;
  • mixing opacity modes. you have “sprite with opacity X” and “sprite with opacity Y”. this means 2 drawcalls.
  • mixing blending modes. same as above.

from what i’ve read in the forums, canvas doesn’t do batch drawcalls.

i’m not sure how the particle system does it with color and opacity variations for drawcalls. would welcome some input on this.

bottom line:

  • separate the text into a different “layer” so that itself will render in one drawcall and won’t disrupt sprite drawcalls;
  • group sprites by opacity and color;
  • consider baking opacities and colors in the texture atlas.
4 Likes

thank for your help.I think you are right.I create many text in prefab because i am making chat popup for my game

Thank for your reply.I test draw call on my android mobile device.i have a list text chat.Each content is an prefab item.Every time turn on chat popup prefab,i instaniate about 45 item text prefab.and draw call change about 200-220.

i think that if you manage to group the text together - regardless if it’s in different nodes/prefabs - it will batch drawcall. you may also try to automatically sort contents of the “chatbox” node, by grouping together text-only nodes and sprite-only (like user thumbnail) nodes whenever a new node is added. but if you have rich text (e.g. mix text with emoticons), then probably you need a different approach.

you could also try to use a bitmap font that shares its texture with your main texture atlas. i use shoebox for all my texture needs and it can create bitmap fonts, but doesn’t seem to be able to reuse an existing atlas for this. perhaps other tools can do it. but, if you need support for other than core european languages, then you need a different approach :slight_smile: