Script Performance: Prefab Instances Versus Mesh Combining

I was watching the Unite08 conference (again) and wanted to run some comparison tests between mesh combining and prefab instances.

http://unity3d.com/support/resources/unite-presentations/performance-optimization

It turns out mesh combining is faster than prefab instances.

The Test: Compare a tree that has 142 verts and 192 faces

340 Prefab instances of a mesh

Versus

340 copies of a mesh combined into a single mesh ~ 65280 faces (just under the 65535 limit)

The result:

  • The nice thing about prefabs is that they use a culling frustum and only draw when in the frustum

  • The bad thing about prefabs is that each instance adds a draw call

  • 340 prefab instances gave ~30 FPS

  • Mesh combining is nice when you have a block of static geometry that is in close proximity that shares the same material. You can blast 65k worth of faces and verts to the GPU in 1 draw call.

  • The bad part is that it’s pretty slow to copy and translate all that mesh data and wouldn’t be a good idea to build in a single frame. It’s not an option that could work for a lot of moving geometry.

  • 340 trees combined to a single mesh gave ~70 FPS

The video:
http://screencast.com/t/Rt8Mxwqm5

This is great for static geometry. What would you recommend for moving or animated geometry?

The sage Neil recommends using a Particle System:
http://unity3d.com/support/documentation/Manual/Particle%20Systems.html

Either use a Mesh particle emitter:
http://unity3d.com/support/documentation/Manual/HOWTO-MeshParticleEmitter.html

Or render the mesh on a texture and create a billboard imposter with a particle system.