i put 100k trees in terrain in unity, and the tree has LOD group, and i made very few trees visible with LOD to player, but still it’s performance very heavy, Why, or does the count 100,000 trees even though they are not visible?
- ! there are no colliders in the tree
- ! the average verts of each tree is 200
- ! there is only one material, the shader is very light, GPU instancing is enabled
Check how many Tris/Verts are being rendered by going to the Game view and pressing the Stats button. See if the number changes if you look away from the terrain. If not, then it may still be drawing trees when they’re off-screen.
Try using the Frame Debugger to see how many trees are being rendered. You can open it by going to Window → Analysis → Frame Debugger. Something to note is that if you open it while playing, it pauses the game and this makes Unity go back to the Scene tab. You may need to select the Game tab again for it to work.
If you have shadows enabled, then even looking away from the terrain may not improve performance that much since the shadows are still being rendered for almost all of the trees, and possibly several times if you are using shadow cascades.
It’s good that you have LOD Groups enabled. For the highest LOD (i.e. the lowest quality model) try using a billboard. Also try increasing the Culled % or disabling shadows on the meshes for the higher LOD levels.
I’ve heard that occlusion culling may cost more performance than it saves when using terrain. There are some tools that convert a Terrain to a mesh which greatly improves performance and makes occlusion culling more effective, although you’d lose the ability to modify the terrain in-game. You could even set this up so it performs automatically when you make a build.
That’s a lot of trees. Tools like this allow you to render them with excellent performance, even on many mobile targets.