- Home /
How to optimize a low poly forest planet with 500+ trees?
I am making my first game with small low poly planets that have some nature on them that is scaled up to be seen from about 10 units away. I have Grass planets with a few (about 25 - 40) trees. Desert planets with a few (also about 25 - 40) cacti. I just placed 108 trees on my Forest planet and they only cover 1/4 of the planet. Most of the trees are tall low poly pine trees (100) with a few oak trees (8) to mix it up a little. The Pine tree has 74 total polygons and the oaks have 220 polygons.
So my question is this: Is just placing 100 - 500 tree objects the most optimized method or is there another way?
I don't care for dev speed improvements just runtime lag prevention. As I want about 500 trees per forest planet and about 5 - 20 forest planets. And 74 x 500 is 37,000 polygons for just the trees alone on one planet and 37,000 x 20 is 740,000 polygons pre galaxy.
New info: The game will spawn in 30 to 100 planets to form a map. Some of the spawn planets will be the densely packed forest planets that are the optimization issue of this question.
Thank you in advance.
First easy improve would be to enable GPUInstancing on the used Material. Some slightly more complicated optimisation is LevelOfDetail. It simply swaps the mesh with an even lower poly mesh if its far away. docs.unity3d.com/Manual/LevelOfDetail.html
should you show player 20 planet and every trees on planet at once?
No, not all 20 forest planets with 500+ trees will be seen at once, but based on how the player moves the camera a few (0 - 6) will be seen. All I really want is a tree-optimized low poly Kashyyyk-like planet that can be randomly spawned in to make a map.
only if 0~6 trees are seen in camera at once, you don't need to worry about performance because unity will not draw trees which is outside of camera view but if you still concerning performance lod(level of detail) system is one possible optimization as other people mentioned
Answer by ster1203 · Aug 20, 2021 at 09:38 PM
One way to optimize for this is LODS, Here is the documentation from unity
You will basically have 3 models in one game object, the first model would be (for example) your oak tree with 220 polygons. The second model within that will have for example 80 polygons and the third with have 20. Depending on the distance the camera will be able to transition between them freeing up rendering memory and reducing load on the gpu.
Answer by Pangamini · Aug 24, 2021 at 10:48 PM
You could create a single mesh that contains all trees from some region, low-poly, and use that as a shared low LOD. Tree chunks close to the camera would render as individual objects, applying standard LOD per tree. Tree chunks far away from the camera would be rendered as a single mesh. Depending on your implementation, you could have hundreds of thousands of trees. But one drawback is that there's no out of the box solution in Unity.
Answer by joan_stark · Aug 24, 2021 at 07:17 PM
As @ster1203 said, LOD's is a good option. Also, i recommend you look for Occlusion culling and Frustum Culling
Occlusion culling makes things stop rendering if are behind other objects, so if you don't see a tree because it's behind another tree, it will stop rendering.
Your answer
![](https://koobas.hobune.stream/wayback/20220613041906im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
3D Meshes: how to minimize error during reduction of order? 0 Answers
Cheap options for making diffuse-lit objects "interesting" 1 Answer
Sharing materials in unity 1 Answer
Is it possible to not allow unity optimise my code? 1 Answer
A question of optimization: use a script with variables or use the object name? 1 Answer