Multiple Shaders vs. Single Texture - Please help me overthink this.

I’m using Maya to model low-poly meshes for a mobile game. I’m assigning materials per-face to color the models. Since each model has several colors, I end up with multiple materials per mesh.

I’ve read on the Unity3d art assets best practices section that single textures on a mesh is recommended because it limits draw calls and optimizes performance. I’ve also read that procedural shaders generated at runtime are a lower performance hit than texture load-ins.

BUT, I don’t have textures - just materials. Since I’m just setting RGB values and not dealing with bitmaps, that makes them procedural, right?

My question is, would I be okay running 5 to 6 unlit/color shaders on a skinned mesh renderer? My model meshes are generally in the 700 triangle range. Or is that going to land me in draw call purgatory once I have 10-12 of these models moving around?

I could bake the materials to a texture map by suffering through some kind of UV unwrap/replace nightmare, but it’s 2016 and how are we even still dealing with UVs anyways. And even after figuring out how exactly to do that, I would end up with an atlas of flat colored polygons, which seems wrong even to me.

Or, I can continue to do what I’m doing, which is importing .fbx models from Maya with per-face coloring and not having to do anything else since it already just works.

Will someone with some knowledge on this please justify my decision to stick with the easier option? Thanks.

The code to create a colored vertex mesh, out of a mesh with multiple textures, is pretty simple, if you know what your doing, but is a nightmare if you don’t. Here is a script that can be attached to a game object. It will allow you to select a mesh, and set of “replacement” colors, that will be assigned to the vertices based on their sub-mesh (material). When you click “process”, a new mesh called “ColorVert”+originalMeshName+“.asset”, will be created in your asset folder.
I do NOT have an model with multiple textures in a single file to test, so I’ve only done very limited tests. (post one and I can test it.)

You will also need a vertex-color shader to actually make this work. I used this one, with default settings, which worked well in my tests: http://forum.unity3d.com/threads/standard-shader-with-vertex-colors.316529/

Here is the script code to colorize a mesh’s vertexes:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;

[ExecuteInEditMode]
public class ColorizeMesh : MonoBehaviour {
    public Mesh meshToProcess;
    public List<Color> colorsToAssign;
    public bool processNow=false;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
        if (processNow)
        {
            processNow = false;
            if (!meshToProcess) return;
            if (colorsToAssign == null) return;
            Mesh tempMesh = (Mesh)UnityEngine.Object.Instantiate(meshToProcess);

            int subMeshCount = tempMesh.subMeshCount;
            List<int> finalTrinagleList= new List<int>();
            Color[] vertexColorArray = new Color[tempMesh.vertexCount];


            for (int i = 0; i < subMeshCount; i++)
            {
                int[] subMeshTrinagles = tempMesh.GetTriangles(i);
                int subMeshTrinagleCount = subMeshTrinagles.Length;
                for (int j = 0; j < subMeshTrinagleCount; j++)
                {
                    int vertexIndex = subMeshTrinagles[j];
                    finalTrinagleList.Add(vertexIndex);
                    vertexColorArray[vertexIndex] = colorsToAssign*;*

}
tempMesh.SetTriangles(new int[0], i);
}
tempMesh.SetTriangles(finalTrinagleList, 0);
tempMesh.SetColors(new List(vertexColorArray));

AssetDatabase.CreateAsset(tempMesh, “Assets/ColoredVert” + tempMesh.name + “.asset”);
AssetDatabase.SaveAssets();
}

  • }*
    }