- Home /
Dense foliage on Android seen from above, performance, can it be done?
I'm fairly new to Unity, so please bear with me.
I'm making a game for Android where you see a terrain from the air, mostly either from the top, or in a 50/60 degree angle (you never see the horizon).
After some optimization, it works quite fast. So far so good.
I need to add some heavy foliage to this terrain, which does NOT need to be of high quality.
So I did some experiments with trees and grass (shipped with Unity), and:
set BILLBOARDING to the lowest (5)
FADE LENGTH 0
MAX MESH TREES 0
DETAIL RESOLUTION PER PATCH 128
Trees have NO COLLIDERS, DETAILS do NOT CAST SHADOWS.
After all this, I'm getting what I think are pretty good stats: - DRAW CALLS: 16-18 average - TRIS: 14-15k average - VERTS: 14-16k average - TEXTURES: 7-9 - VRAM: 20-25MB - VBO: 33-35 1.4MB
Still, on Android it is quite slow (let's say some 10/15FPS for reference on my mid-range device). Since I will need to add heavy scripting, AI and objects later, those numbers are only bound to go down, so I want to solve the problem at this point.
So my questions are: 1 - How are the trees/details slowing the game down (as in "that bad STAT that I should be seeing but don't"), and how can I optimize this.
2 - I there a workaround / tip / trick that I can implement to make it LOOK like there is a lot of foliage, keeping in mind I will NEVER see the terrain from the ground? (objects on the ground need to be partially hidden by the shrubs, so I cannot just make a terrain texture)
Any advise will be welcome. Thank you all in advance.
Answer by Razorwings18 · Jun 22, 2014 at 08:20 PM
I guess I answered myself on this.
While I'm not positive, the problem may have been that billboarding a lot of trees one next to the other caused a lot of overdraw. I did make a test where I placed diffuse billboarded objects (no alpha) instead of the trees, and performance was still quite low.
Anyway, my solution was I ended up tiling a bunch of Quad meshes next to each other that hover over the terrain, and assigned a material with a texture that looks like tree canopies in a forest, with transparency. I used that on the fastest unlit Alpha Blended shader I could find.
The result was visually pretty good, and with ultra fast performance (somewhere around a 3 FPS drop average on my device for a full screen of forest, a single drawcall for everything, and just 2 tris, 4 verts per tile).
Since my terrain has hills, I complemented the solution with a script that moves the quad vertices to a set height over the terrain, so the forest can conform to them.
Screenshot attached, showing how characters look (white for clarity) through this forest.