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

Low FPS with Terrain on Mobile Devices

Discussion in 'World Building' started by RIw, Jun 25, 2018.

  1. RIw

    RIw

    Joined:
    Jan 2, 2015
    Posts:
    90
    Hello!
    I'm working on a Mobile Game in Unity3D.
    Finally I've added some real terrain to my Levels, and everything works fine on my PC, but after exporting to my Mobile Device (Samsung Galaxy S5) I'm experiencing really noticeable FPS loss (from 60 to 20).
    I thought that my Terrain is not optimized, but even after lowering Texture's resolution nothing has changed.
    I've made a small test and I've replaced that terrain with base Terrain from Unity (white plane without any extra settings) and then I'm getting 40 FPS on my mobile device. Is more than 20, but It's still weird for me.
    I don't know what I'm missing. I would be really grateful for any help.
     
  2. ForceVFX

    ForceVFX

    Joined:
    Jan 21, 2011
    Posts:
    612
    don't use terrains, convert to object files and replace with meshes....
    Free Terrain Obj Exporter....and use built in profiler, to identify whats causing the slow down..
    somewhere in your code set application frame rate to 60/120..It defaults to 30..(search set target frame rate in unity)..the frame rate in unity editor, is NOT, relevant to the actual device..attaching device in debug, building and then running profiler, will give you true feedback

    that helped me, on my first android game.

    p-
     
    tree_arb likes this.
  3. RIw

    RIw

    Joined:
    Jan 2, 2015
    Posts:
    90
    @ForceVFX Okay thanks, but can you tell my if is there any way to export "final" texture of the Terrain, to attach it to my *.obj file ?
     
  4. ForceVFX

    ForceVFX

    Joined:
    Jan 21, 2011
    Posts:
    612
    thats the issue, I was looking for a simple 4 splat mesh shader for ya...I will let you know when I find a free one..
     
  5. RIw

    RIw

    Joined:
    Jan 2, 2015
    Posts:
    90
    @ForceVFX Ok, thank you very much for your help. I noticed that using this exporter solved the issue with FPS, I only need some way to get that texture working on that *.obj.
     
  6. RIw

    RIw

    Joined:
    Jan 2, 2015
    Posts:
    90
    @ForceVFX Hi. Did you find anything like that so far?
    I found myself only one tool that could handle this job, but it's not free :( .
    I can't believe that it's not a common problem so someone (even Unity team itself) could create Open-Sourced solution.
     
  7. ForceVFX

    ForceVFX

    Joined:
    Jan 21, 2011
    Posts:
    612

    I could not find a free one either, so I wrote you a simple one..sent a private message

    p-
     
    Last edited: Jul 9, 2018
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,798
    I found a GPL'ed splatmapper by following links at the bottom of this video:

     
    JoeStrout likes this.
  9. RIw

    RIw

    Joined:
    Jan 2, 2015
    Posts:
    90
    @Kurt-Dekker Thanks, but it's just the shader right?
    How should I extract all the textures from my *.terrain to use them with this Shader ?
     
  10. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,798
    The primary textures are just those entered into the Terrain script on the actual object. Select the terrain in scene and use the editor to get which textures they are.

    If you need the splatmap, you can either write code to pluck it out of the TerrainData within the Terrain, or you can drag-drop reference it into any Monobehavior directly from the sub-entry under the Terrain asset in your project. See snapshot:

    That is a Texture but you can get at it as a Texture2D field too, i.e., dragging the reference into:

    Code (csharp):
    1. public Texture2D theSplatmap;
    This is what it looks like inside your Terrain asset:

    Screen Shot 2018-08-02 at 10.53.36 AM.png

    Pretty sure that this textures color coding won't automagically align with the way you setup your shader, but you can make it so, as long as it has less types of terrains than the Shader supports, which I think is 4.
     
    tree_arb likes this.
  11. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    306
    Good thread. Mesh in place of terrain has significantly increased fps on android for me.

    To get my multi-texture terrain back, I was able to use the splat map shader kurt-dekker posted a link to, as well as his instructions to reference the splat map generated from the original unity terrain.

    This is great but the splat shader is a bit slow.

    I then found this other splat shader to perform faster, and again reference the original unity terrain splatmap.

    https://tech.innogames.com/terrain-shader-in-unity/

    It does well, but ultimately the fastest thing i can get working for an older mobile device seems to be take the background mountains terrain for example. Optimize mesh, 1 texture, no normal maps, basic mobile shader, no splat. With that combo theres basically no hit to fps at all.

    It anyone knows a way to make the splat shader as fast as basic mobile shader that would be ideal.
     
  12. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,848
    We've switched to MicroSplat for our mobile mesh terrain needs. Used properly (and the docs explain how to do that), it seems to be quite fast.