|
Hi, I'm trying to optimize my drawcalls on an iPhone project, and it's my understanding that changing the material color generates a new material instance and hence another drawcall. I read in the forums that using a VertexLit shader and modifying vertex colors will let you change the color of an object and still keep it dynamically batched. I don't know much about shaders, but in my code I am modifying the "material.color" property, thinking thats how you change the Vertex colors. It's still creating a new material though, so I must be doing something wrong. So given two objects that share the same material, object A and object B. How can I make: A = red B = blue and still keep batching? here is a code snippet of how i'm currently doing it
(comments are locked)
|
|
You have to change vertex colors by changing the actual colors of the vertex color array from a mesh. Changing material.color only changes the color of the material.
(comments are locked)
|
|
You could render them with individual colors in one batch using Graphics.DrawMesh and MaterialPropertyBlock: http://unity3d.com/support/documentation/ScriptReference/MaterialPropertyBlock.html
(comments are locked)
|
