Forest of Trees?

Well... The thing is that my game requires a forest, of sorts, which means loads of trees...

However, the problem is that the Unity3D trees appear to lag when we use them en masse, and it also lags even with our own trees.

So the question is, does anyone know how to make a convincing forest of trees? Either that, or is having alot of trees supposed to lag badly? Because perhaps the problem isn't the trees, but my code...


Using terrain trees gets you so much more than any other method that it's worth it to figure out how to optimize them.

  1. Billboard distance rarely needs to be more than 50-75 m away, even at very high quality settings.

  2. Fade distance of 10 m or so will help with the snapping.

  3. Depending on how close the trees are together and how dense they are, something like 30-50 mesh trees max is plenty.

  4. Make sure most of your tree models are well under 2,000 polys. 1,000 - 1500 is adequate with clever panels for transparent groups of leaves and branches as textures on planes, of course depending on their shape.

  5. Remember that shadows on anything cost a lot, so don't judge overall performance with realtime shadows on.

Billboarded and lightmapped terrain trees can look great and have relatively low draw calls and high frame rates.

Also, you can't lightmap the AO tree shaders if they are placed as standalones, or with the combine children script. So you lose lightmapping if you go that route (3.0)

Edit about lightmapping hand-placed trees: You can set a hand-placed AO tree to static and lightmap it in order to get its shadows on the ground. But the model itself won't be lightmapped, and will always use real-time lighting.

Reducing the sliders on the terrain generally helps reduce the taxation of drawing so many trees. You'll sometimes run into 'snapping' from trees that are coming into billboard distance though, which is unfortunate. I've seen some people have success with low-poly tree meshes added to the game then combined with the mesh combine utility. If you do this, avoid having too many mesh-colliders as your performance will then be caused by physics (making prefabs of the trees with a capsule collider is usually sufficient).

Run the profiler and get some data on whether it's the graphics (draw calls) of so many trees or the physics of the tree colliders that is your biggest bottleneck (or possibly both), then take steps to reduce the draw as you would any other mesh or collider.

I don’t know if unity has implemented this, but the game shouldn’t be instantiating trees, it should be making 20 groups of say 100 trees at start-up, and when they need to be in view, move them from somewhere in outer space onto the scene and recalculate all their positions in one loop, that way the trees are all in memory they just have to be repositioned and adjusted to the terrain contour. and trees in a group that shouldn’t be visible just stay a couple of miles under the group, at the same time as its calculating the contour.