2 draw calls per mesh?

I have a bunch of meshes in my scene, both animated and static.

Each of them has a simple diffuse shader, however each of them requires 2 draw calls.

Shouldn't they only require 1 draw call? Is there a reason for needing 2?

3 Answers

3

Draw calls aren't related to materials, but shaders and light sources and other factors (forward rendering vs. diffuse, pixel lighting vs. vertex lighting, etc.). Forward rendering with the default diffuse shader requires a draw call for the object and another one for each pixel light, although it depends on the version of Unity...Unity 3.3 seems to have only one draw call in this case, with an additional call for each pixel light.

Nice, simple and accurate explanation. +1

Here's a link to Unity's Forward Rendering explanation page, it's a good read, along with the other render paths if you feel like broadening your understanding. http://unity3d.com/support/documentation/Components/RenderTech-ForwardRendering.html

It appears as though the number of draw calls is reduced to one if an object's material is removed....I was under the impression that an object with a material (at least, a simple material) only has 1 draw call. Guess I was wrong.

Since materials are what holds the texture and the mesh is, err, well the mesh it will need two draw calls. One for drawing the texture/material and one for the mesh.

Eg. if you make a mesh with a material using the toon shader you'll need three draw calls (if I'm not mistaken?), one for the mesh, one for main texture and one for the ramp that the shader's using for shading.

//btw sry for the grammar, I've caught the flu and the head's spinning.

Sorry to downvote someone with the flu, but that's not how it works. An object with a material that uses a vertex-lit shader, for example, will have only one draw call. An object using the toon shader has one draw call.

In response to seeing this thread, I tried an experiment. I took out all of the point lights from my scene and set my shaders to self illuminated diffuses. Since I have stylized (cartoon-ish) graphics in my project and I'm not worried about any real time lighting effects. This dropped the draw calls down to one for each object, and boosted my framerate quite a lot, which was really nice because it's an rts with lots of animated meshes on screen. Thanks for the info ladies and gents.