- Home /
Unity Android lag when close to terrain
I have a simple Unity Android scene with a terrain with some textures. There are no trees, grass etc. and the texture-size is very low. I test my game on high-end devices.
Usually, there are no problems when I'm making terrains for Android, but something went wrong here. When my camera is close to the terrain, the framerate drops to about 15FPS but if my camera is 100 meters above the terrain (facing down), the framerate is about 40-50FPS. I have tried this:
Changing camera Far Clipping Planes Remove textures from the terrain Set basemap distance to zero.
There are no problems in the editor.
I have spent a lot of time on this terrain, so I really don't want to start all over...
Thanks in advance.
Andreas.
You should print out the draw calls, because it sounds like geometry, and print them out on the other terrains that work fine for you, then compare. Other terrains may have worked okay on mobile due to the terrain structure, i.e. low detail needed to represent the terrain. If this one has more areas of movement (up/down in height), then it can't be optimized, and you end up having to draw more geometry. So when you are close up, the geometry near you will be of the highest detail, and if you are looking at a shallow angle, you will see lots of terrain to the distance, and it will be optimized to render LODs based on the detail (what it can get away with) as well. Curiously, if you turn on the wireframe of the terrain, you can see what I'm talking about.
So, every terrain in general will behave differently. The reason you would get good frame rate above the terrain is because it goes to low detail and reduced geometry. I doubt your textures are the problem. $$anonymous$$ore likely, the problem is that you're using the built-in terrain engine which is not optimized for mobile. You may want to consider something like T4$$anonymous$$ in the asset store (terrain for mobile) or similar.
I see what you mean. It's clear to see, that the draw calls are reduced about 60% when above 100m. Verts go from 750k to 150k. Render textures go from 14mb to 0mb. It must be the geometry and low detail. Is it possible to set the geometry to lower detail, without having to reset the terrain?
Hahah... I just figured out there was hidden a lot of polygons in my player model. Wonder why it only lagged when it was close to terrain though.. Anyway, the problem is solved! Thank you very much for your help :)
Oh, well if you use some character controllers, when you zoom the camera in close to the player, it turns them transparent, so that probably had a large hit if doing that. But you also get the same effect, depending on your character model, if it has multiple level of details. Glad you solved it though.
Just curious... When my game get's a lot of polygons it would probably begin to lag again.. As you said: "The reason you would get good frame rate above the terrain is because it goes to low detail and reduced geometry".
Is there a way to make it stay at low detail and reduced geometry no matter how close the player is to the terrain?
Your answer
Follow this Question
Related Questions
Problem with Android Framerate Dropping 2 Answers
Terrain Lag Issues : Trees 0 Answers
Input lag on Andorid but not in Unity 1 Answer
Interstitial ad kills framerate in different scene. 0 Answers
Android device LG G3 Frame rate problem 0 Answers