2 materials on one mesh = 2 draw calls?


i have 2 materials for one mesh, my character, which has a jersey (the first material) and a number on the jersey (i used a second material to assign exactly the vertices and avoid the stretch effect, and each jersey will have its specific number). So i am not sure about the draw calls: does it mean unity call twice to paint each material on the same mesh?

thanks a lot

A change in material means settings in the rendering pipeline need to change, so that will require a new drawcall with the new material active.

FWIW: I’m new to Unity (but not graphics in general) so I’m about 70% certain this is the case. For example, I’m not sure how efficient batching of materials might be under the hood, which might minimize the number of calls across the whole scene, but in the case of that particular mesh, each material needs to be “drawn”, hence your two drawcalls.

You will get one draw call per material you use inside of Unity. So to avoid this, you could use one material that accepts two textures and combine then inside the shader, instead of using two shaders (two materials) to show the two textures.

Create a new Shader and paste this code in it. Then add one material to your mesh and choose ‘TextureCombine_One_Drawcall’ shader from the shader drop down.

Shader "TextureCombine_One_Drawcall" {
Properties {
	_MainTex ("Base (RGB)", 2D) = "white" {}
	_SecondTex ("Base (RGB)", 2D) = "white" {}
SubShader {
	Pass {            
            // Apply base texture
            SetTexture [_MainTex] {
                combine texture
            // Blend in the _SecondTex texture using the lerp operator
            SetTexture [_SecondTex] {
                combine texture lerp (texture) previous

Fallback "VertexLit"

Obviously you could optimise this shader a lot. But this should be pretty decent in terms of performance.

Hope this help.