Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: gecko64 on December 16, 2014, 08:59:21 PM

Title: Several draw calls per sprite (only sprites in the panel)
Post by: gecko64 on December 16, 2014, 08:59:21 PM
I've got a game with a lot of panels -- at runtime, between 15 and 40 UIPanels are distributed across a starry-night skydome, representing astronomical objects. They're on a GUI layer is not affected by any lights, and only one camera is set to render that layer. Yet each sprite in each panel uses 2-4 drawcalls. I've read the various threads about this type of issue, but I don't think any apply. These panels are very simple: each one has about ten sprites in it, all of which use the same atlas. There are no dynamic fonts or anything else but sprites in the panels.  The panels revolve around the camera with the skydome, but the contents in each panel are static, so I've checked the "Static" toggle on each panel, and also checked the "Static" box on each sprite object.

I don't think that it's caused by 3.x's depth function, since there's nothing but sprites in these panels, and they all use the same atlas. There are several other GUI panels onscreen at the same time.

Any solutions or suggestions? It's really dragging down the frame rate.

thanks
Dave
Title: Re: Several draw calls per sprite (only sprites in the panel)
Post by: ArenMook on December 17, 2014, 03:14:23 PM
Different panels = different sets of draw calls. 40 panels means at least 40 draw calls. If all widgets share the same exact atlas, then it will be exactly that -- 40 draw calls. You can always debug the draw calls by opening up the draw call tool.

I strongly advise reducing the number of panels. Why do you need so many?
Title: Re: Several draw calls per sprite (only sprites in the panel)
Post by: gecko64 on December 17, 2014, 05:14:03 PM
We have that many panels because each panel represents a different astronomical object, which needs to be placed on a skydome (inside a sphere), so it can rotate with the starry night.

I don't mind 40 drawcalls for 40 panels, but it's far more than that. (When I disable the parent of all these panels, drawcalls drop by about 300.) Attached is the Draw Call tool for one of those panels, showing many drawcalls for the sprites inside that panel.

I tried disabling all but one of these panels. After doing that, and then toggling individual sprites on and off, some use just a single drawcall, but others still use 2-3. Any ideas?
Title: Re: Several draw calls per sprite (only sprites in the panel)
Post by: dubbreak on December 17, 2014, 10:54:09 PM
Are you using more than one atlas per panel? As ArenMook mentioned, 1 atlas means 1 draw call for that panel. I always stick with one per panel otherwise you can get some weird stuff happening with depth culling.

Do you really need that many panels? I could see using a few around the sphere, but with a perspective camera you can mess around with the sprite Z depth and it works (as well as 3d rotation etc). I'd think 6 panels would be plenty (if not overkill). Make a box within the sphere, push stuff back to the level of the sphere via Z coords as necessary. But maybe I don't understand what you are doing.

Could also be the wrong tool for the job. I abuse NGUI on a daily basis using it as a sprite manager. It works for me and my usage, but that's not what it was designed for.
Title: Re: Several draw calls per sprite (only sprites in the panel)
Post by: gecko64 on December 18, 2014, 10:21:46 AM
We have one atlas per panel, yet lots of drawcalls per panel. We need to have one panel per astronomical object, for various reasons.

I understand that it's a lot of panels, but it still seems like something isn't working correctly -- we have 40 panels, we should have 40 drawcalls, but instead we have over 300 drawcalls. If in fact we *should* have 300 drawcalls, then NGUI may not be the right tool for the job...but so far nobody is saying that we should have 300 drawcalls with this setup.
Title: Re: Several draw calls per sprite (only sprites in the panel)
Post by: ArenMook on December 19, 2014, 07:32:24 AM
What version of NGUI are you using and what version of Unity? Your draw call's render queues are not even consecutive numbers...
Title: Re: Several draw calls per sprite (only sprites in the panel)
Post by: gecko64 on December 19, 2014, 12:00:16 PM
I was still on 3.0.7. I just upgraded to the latest version and the problem is fixed!! Huzzah!

And obviously, I should have upgraded before complaining. Sorry about that. :/