Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Terrain alternative for mobile?

Discussion in 'Editor & General Support' started by SuperVoximus, Sep 18, 2016.

  1. SuperVoximus

    SuperVoximus

    Joined:
    Nov 5, 2013
    Posts:
    102
    I have a flat 500x500 terrain in my android game. I plan on keeping it completely flat, but I used it instead of a big plane because i can texture paint on a terrain.

    I was using 1 plane per texture prior to this (it's a tile based game) but i ended up with waaaay too many planes and loading times were getting out of hand,
    however i was on stable 60+ FPS.

    I switched the planes for a flat 500x500 terrain with 5 textures with Legacy/Diffuse shader and it went down to 39FPS. Turned it off, back to 60+FPS.

    I don't quite understand since the terrain is flat without trees/grass, and I don't think I have enabled any weird performance hogging options.

    What should I do? Is there a way I can take the terrain texture and slap it on one giant plane? Or maybe some sort of alternative for the terrain?

    Any help is greatly appreciated!
     
  2. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    Why not try the Mobile > Diffuse shaders instead of Legacy > Diffuse?

    Also, by terrain, you're saying it is completely flat. Is your terrain actual "terrain" made with the Unity terrain tool, or is it just a cube or plane?

    Also a screenshot of your game might be helpful to see what's the best solution.
     
  3. SuperVoximus

    SuperVoximus

    Joined:
    Nov 5, 2013
    Posts:
    102
    First of all, thanks for the reply!

    I wanted to, but I only had the option between Standard, Legacy Diffuse, and Legacy Specular. If I try to make a custom one, rather than being able to pick a shader, I am forced to pick a material, and if i pick a material with mobile shaders I get a tangent geometry error.

    It's a terrain made with unity tool but it's 100% flat, the only difference between that and a plane is the texture painting.

    I've attached a screenshot of my game, as you can see it's just the terrain and some low poly trees with disabled shadows (texture painted darker around the trees to simulate shadows). In that screenshot I'm at 4.2k polygons, everything is static except for the character, 7 Setpass Calls.

    On my Galaxy S3, when I disable the terrain it goes straight from 39FPS to 60+.
     

    Attached Files:

    • Game.png
      Game.png
      File size:
      1.5 MB
      Views:
      1,235
  4. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    Well, terrain isn't supposed to be such a drag. You'll have to try to optimize it.

    Select the terrain, in the inspector you'll see the settings icon by the brushes. Since it is completely flat, you can play with the settings and set them to pretty low quality. For me, drastically increasing pixel error and lowering the Detail Distance gave me much better results on large terrains with hills. Also you can lower the Height map resolution to the lowest it allows you (for me, 33). Play with the settings!
     
  5. SuperVoximus

    SuperVoximus

    Joined:
    Nov 5, 2013
    Posts:
    102
    Alright I'll try! If I get any luck I'll share! :D
     
    DroidifyDevs likes this.
  6. SuperVoximus

    SuperVoximus

    Joined:
    Nov 5, 2013
    Posts:
    102
    Well, I'm back to 60FPS (dips to 55 but thats fine). And the reason was quite perplexing for me, I removed the static tick from everything, and it's running a lot faster now, I don't know why though lol
    Edit: After adding a few extra textures all hell broke loose, the terrain is unusable for me at this point, will have to find an alternative sadly
     
    Last edited: Sep 18, 2016
  7. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    Why not go to Window > Lighting and see if you had Precomputed GI on... that would explain the dip in performance with the static tags. Static tags should be used on objects that don't move, then you can bake lights and save on performance. However if it is running 60FPS I don't think you need much optimization. What Android device are you testing on?

    Also, did you increase the pixel error and lower the Detail Distance as I said?
     
  8. SuperVoximus

    SuperVoximus

    Joined:
    Nov 5, 2013
    Posts:
    102
    I'm on a Galaxy S3.
    Yes I did so and it was running better until I added a few textures, I plan to have a bunch of more textures too so it's looking problematic now.

    I've heard of exporting the terrain splatmap and applying it as a texture on a mesh, do you think that would help?
     
  9. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    You could try that! I'm terrible at art so I have no idea on exporting a splat map and applying on another mesh, but that could improve performance. Anything is worth a shot! However I recommend you set up the Static tags again and start looking into light baking. Or consider trying the game with no shadows as a "quick fix".
     
  10. SuperVoximus

    SuperVoximus

    Joined:
    Nov 5, 2013
    Posts:
    102
    Alright, thanks for all the help, I'll try a few things and if I make any progress I'll post back in case anyone has similar issues!
     
    DroidifyDevs likes this.
  11. SuperVoximus

    SuperVoximus

    Joined:
    Nov 5, 2013
    Posts:
    102
    Okay, that went horribly wrong XD

    My options now are:

    1) Go back to 1 plane per tile (Decent performance for me, but slightly worried about the amount of gameobjects).
    2) Cut my map into small parts (5-7 areas)

    Do you think having thousands of gameobjects (although a very small amount visible) in my scene would cause problems? I'm sitting at 700 trees for my forest area, and I'm estimating around 5k total planes or so.
     
  12. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    If you use Occlusion Culling, lots of objects shouldn't be a problem. What's really helping you is that it looks like it is a top-down game, so you can really cut corners on everything the camera doesn't see.
     
  13. SuperVoximus

    SuperVoximus

    Joined:
    Nov 5, 2013
    Posts:
    102
    Yeah, I went ahead and just used single planes. It's unbelievable how I NEVER dip under 60FPS now. It's running very smooth. The only problem I am having with a large amount of gameobjects now is loading times. You can battle enemies which takes you to another scene, and then you go back, loading time on my Galaxy S3 is around 7-8 seconds, which doesn't seem too bad, but I'm afraid it'll kill the fast paced nature of the game.
    I think I might split my world into a few smaller levels which should help out.
    The Galaxy S3 is a bit old now but I'm not sure how newer phones stack up against it in performance. Hopefully it's slower than the average device I should be aiming for.

    It's been quite a stressful few days for me and I really appreciate all the help you've given me so thanks again!
     
    DroidifyDevs likes this.
  14. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    Maybe instantiate the enemies in your current scene instead of loading a whole new scene?
     
  15. SuperVoximus

    SuperVoximus

    Joined:
    Nov 5, 2013
    Posts:
    102
    It's sort of like turn based combat with a completely different system. Now that I think about it though it would be cool to have real time combat instead :D
     
    DroidifyDevs likes this.