Drawcalls not adding up

I’ve been testing one unit in my game to see how many drawcalls it takes up and it’s not adding up to what I think it should be. My unit has one material for the body, one material for a sword, one material for a shield, one material for the projector it’s using, and the healthbar takes up 2 materials.

That should be 6 drawcalls maximum from what I’ve read and been told, however in-game my stats window increases by 10 drawcalls when the unit enters the screen view.

So, the editor says the unit takes up 10 drawcalls, when it should only take up 6 drawcalls from what I know? It matters because I’m going to have lots and lots of these units in my game. I’ve made sure the unit has no renderers that cast shadows, and I’ve inspected the rig, the skinned mesh renderer, and the other mesh renderers to see if there are any I missed. As far as I can tell, it should only be using 6 materials total.

If I use a shader that takes normal maps (and use a normal map with that shader) does that add an extra drawcall? What could be causing 4 extra drawcalls? Thanks for any help.

Try to deactivate the projector and see if you get the expected amount of draw calls. Projectors have more than one draw call.

not to mention is it forward or deferred rendering, how many lights in the scene, and do any cast shadows… oh and obviously what kind of shader?

Ok, I tested it with the projector disabled/off and it only used up one less draw call. So with projector off, it uses 9 drawcalls. With projector on, it’s 10 drawcalls.

@kurylo3d:

I am using forward rendering since I only have Unity free version. There is one light source in the seen and it’s a directional light (used as a “sun”). I made sure the renderers don’t cast or receive shadows, but there are other objects in my scene that do cast shadows, yes. I am using the “Bumped Specular” shader for the unit itself, a “Custom/Projector1” for the projector (see above), and the healthbar uses a “Transparent/Specular” shader for the parent object, and a normal “Diffuse” shader for a child object.

Any thoughts?

Ok after testing it for awhile, I kind of figured out that maybe my testing methods were bad – maybe :wink:

My intial way of testing was to move my unit out of view of the camera. Then without moving the camera at all, I would see how many drawcalls there were initially, and then move my unit into the camera view (test area), and simply see how many drawcalls the unit added as it came on-screen (taking into account when it was visible).

Then, I decided to create a new scene, with all the rocks, other units, buildings, etc. stripped from it. And now, when my unit comes on-screen (i.e. is visible), it’s showing the correct amount of drawcalls. My guess is, I had another unit that for some reason the game said was “visible”, even though it was far off-screen, and perhaps it was doing something funky with the batching or whatnot that caused it to show 4 more drawcalls than it should have.

Overall, I think the stats are correct, and not really doing anything wrong per-say, other than saying that some units which are not visible from a human perspective, ARE actually said to be visible by the camera.

Maybe one of my units’ transform box thingy (I don’t know what you call it) was not correctly set in a 3d application program, and somehow the camera always says it’s visible lol. I don’t know how to fix that though, but it’s kind of annoying. I don’t know what’s causing the visibility issue.

Anyways, thanks for the help, I guess it’s another issue now.