Hi guys, I’m using MeshMerger to create a skinned mesh from hundred of cubes.
This is the link for the merger:
http://wiki.unity3d.com/index.php?title=MeshMerger
I want to color each vertex and using it with a simple shader. I notice that assigning the mesh.colors causes a loss of 10fps on my game.
This is the snippet for the mesh config:
// hook up the mesh
Mesh me = new Mesh ();
me.name = gameObject.name;
me.vertices = verts;
me.normals = norms;
me.boneWeights = weights;
me.uv = uvs;
me.colors32 = colors;
me.bindposes = bindPoses;
me.triangles = tris;
me.Optimize();
and this is the shader:
Shader " Vertex Colored"
{
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
}
Category {
Lighting On
ColorMaterial AmbientAndDiffuse
ZWrite On
Cull Back
Blend Off
SubShader
{
Pass {
SetTexture [_MainTex] {Combine texture * primary Double}
}
}
}
}
ColorMaterial AmbientAndDiffuse overwrite the ambient and diffuse color with the color of the vertex.
If I comment “me.colors32 = colors;” I get the original performance.
I don’t have a clue on what’s going on… assigning a color vertex shouldn’t affect the performance at all.
Any ideas?