- Home /
Can I have 500,000+ trees?
My game lets the user run a simulation of environment over many years. The problem is that the environmental model will sometimes generate a year will 500,000+ trees, sometimes almost 1,000,000! While you can still click on the trees, I am not using colliders (which would cap me at ~65,000). When I try and render a environmental model, I am getting the following error: "Fatal Error - Out of Memory". It works during years with <~500,000 trees.
My guess is that Unity is just unhappy with the amount of rendering that is being requested. Is this correct? Also, are trees being rendered even if they are not in the camera's line of site (hidden by terrain or behind camera). Is there someway to further optimize the billboarding of trees in the far distance? I was thinking maybe there is some way to dynamically apply a different texture to the most distant terrain instead of drawing the trees? I would like to preserve the visual effect I have in the below picture (that is about 200,000 trees in terrian).
Answer by Screenhog · Aug 15, 2012 at 04:37 PM
Yes, 500,000 trees is too many.
Can you actually visit those far-away areas? Or do you just like the effect of having that many trees, without the need to actually go there?
If you don't need to go there, then there are many possible ways to cheat it. If you do need to go there... well, it still can be cheated, but you have to be more creative about it.
Unfortunately, client is still requesting to be able to travel to all those areas. It is a 4sq km model of the Quabbin Reservoir in $$anonymous$$assachusetts http://goo.gl/maps/98uot . Any ideas about how to be more creative? :)
Ah, O$$anonymous$$... geographical accuracy is required.
Well, many games with large open worlds will divide a scene into multiple levels that are loaded as needed. LoadLevelAdditive (http://docs.unity3d.com/Documentation/ScriptReference/Application.LoadLevelAdditive.html) and LoadLevelAdditiveAsync are created for this purpose.
Some games, like the 3D Zeldas, will do this by having levels divided by some kind of corridor... the only purpose of the corridor is to give the game enough time to load what's on the other side of it.
In an open environment like yours, this may be more difficult. However, you might be able to have low polygon versions of entire islands in the background that convert to high polygon versions when you get closer. I don't know how well that will work with the terrain system, though.
Answer by fabmagic · Aug 16, 2012 at 04:08 AM
You can do it with lod level of detail You can have 3 kind of same tree low medium and high res The closer to the cam they switch by themselves Also with occlusion culling Also have just planes with picture of tree billboard technique Just some suggestions Cheers
I'm not sure you realize the scale of this. He's already using the terrain system, which makes billboards of far away trees, but when you have 500,000 trees, that's a million polygons even if each tree is a 2 triangle plane. That can be a lot to deal with.
Your answer
Follow this Question
Related Questions
Trees - Lightning bug 1 Answer
Trees not lighting properly 0 Answers
Dynamic Lightmaps? 1 Answer
Max mesh trees for terrain does not work. 1 Answer
Tree batching inside of terrain 0 Answers