I am trying to do a chess-like board of arbitrary size. Each square is actually a box primitive, which (when I am done scripting) can be scaled to arbitrary height.
The effect would be similar to a chess board with varying heights of the individual squares. The goal is to use it for war games and role-playing games. Now, a board size greater than 31x31 starts to seriously impact performance (though I do have 5 light sources, so that might be part of the problem).
I’ve run across the Mesh.CombineMeshes function, and I understand the basics of draw calls so I know why this is a good idea. But will I still be able to manipulate the scale of individual boxes within this combined mesh? Will I be able to separate boxes from the combined mesh again? How does colliders work with this function?
If anybody has some information or ideas on how to solve this, I would be grateful to hear what you have to say.
No…if the scale of the individual boxes changes rarely, it might be simplest to delete the combined mesh and recombine when the scale changes. Otherwise, it would be best to construct the mesh yourself using the Mesh class and manipulate the appropriate vertices.
Or you could potentially wait until Unity 3 is released, since Unity iPhone has dynamic batching, which would reduce draw calls in cases like this without having to manually combine meshes, and you can keep objects separate. I’m assuming that Unity would also get this feature since it’s pretty useful. It’s not as fast as making the mesh yourself and manipulating vertices, but it’s certainly less complicated.
Can you elaborate on that? Would it be something akin to deleting the whole mesh, then reconstructing all cubes and re-combining them into a new combined mesh? Or can I “un-combine” meshes?
If I should decide to use the Mesh class to construct the whole thing, do you know of any good introduction material?
Great stuff, thanks a lot! It looks like my deadline is too close to start on this, but I’ll definitely give it a closer look when I get to the next iteration.
Combine meshes for display only, but keep the original of the mesh collier and set the renderer to false, once the object need to move or scaling, resume the original then re-combine them again.
Normally, re-combine again again for small amount of object is super fast. except you need something like that…
You may need more work for regrouping the mesh by location or some others methods.
Plus, vertexLit shader is almost 2-3 times faster than diffuse shader. So that, optimize your shader may get better frame rate.
Also, pre-calculate the light information onto ambient occlusion map or lightmap may made the scene use less light too.