Combining meshes

Hi,

I was wondering if I understood it right.

If I want to make for example a level like the screenshot below

That path is mainly built up from flattened cubes (being 1 with some kind of grass and 1 with wood)

Can I build a level out of cubes and then combine these to 1 mesh with all geometry which has the grass + 1 mesh with all geometry containing the wood ?

Would that result in only 2 drawcalls being used under normal circumstances and if all meshes are 1 solid path that doesn’t move ?

How would that have to be done? preferably at runtime.

That’s the basic idea behind the Mesh Combiner script. (It assumes no parts of the grass or wood move)

Keep in mind that if you use a combined mesh over a very large span, that all the offscreen portion of the mesh will be drawn as well. This may make performance worse than just rendering only the objects in view, I’d say try it and see since it only takes a few lines of code.

OpenGL culls polygons that are outside the view frustum, so they aren’t drawn. I believe all the vertices still have to be transmitted, though. The bigger problem with huge meshes is actually to do with pixel lighting, where pixel lights that are affecting distant parts of the object cause the whole thing to be rendered in multiple passes. Whereas if the object was broken up, then distant lights wouldn’t cause that problem.

–Eric

I intend to use vertex lighting instead of per pixel to speed up the things.

I don understand that this disables some nice tricks for me like shadowing, but its performance that counts