The Secret to Great Terrain on Mobile

Hey I was looking at your game you made (the massive open world one)
And was curious, how did you make it where it’s literally massive without
performance killing the machine?

A few people messaged me and asked me what my secret was to detailed terrain on mobile, so i thought I’d share my experience in general here:

First, i don’t do anything particularly special. I’m more of an artist that a coder, so doing things like optimizing shaders etc is beyond me. My approach is pretty straight forward.

I think having a mobile mindset in general is important to optimization. I come from a flash background where performance over a broad range of computers was important, so as a general rule i ‘think small’ and try to optimize everything i do. Since iPhone 4s i have been able to get 2x2km terrains running with trees and textures.

I make sure each texture is as small as possible without looking too blocky. I use a plugin called Resource Checker:

It’s amazing. I use it to go through every texture and shrink to largest ones. This is important because having too many high resolution textures will fill up RAM fast and crash your app.

is it possible to have some of your experience on how you optimise vegetation/tree/grass what shader you used
I don’t use any special shaders or anything, just regular Unity trees. i do limit the detail density and distance though.

are they like painted object on terrain ?
To place objects and vegetation i use Terrain Composer:


The author is brilliant and the plugin is indispensable. AFAIK it just places the objects for you, and performance is the same as if you painted them on the terrain by hand

do they have lod?
No LOD in my projects but that’s because of time constraints, not desire, When i get some more time i will take a look at that

do you use occlusion ?
This is a must on iPhone. Unfortunately in my experience Occlusion changed in Unity 4.3 and has been buggier (more false positives, slower overall, less stable feeling) but that said it’s still essential.

I limit my tree distance and the max number of mesh trees to about 16 to keep performance high.

Im more interested with the overall look an atmosphere of the Open World Wilderness so im not afraid to lower textures or have resolution, antialiasing etc be set very low . I think this mindset helps.

even a 2000 x 2000 terrain kills my performance, at least on Unity 5 it does
you should be able to run it on IOS. I would look at every little thing to see where you can optimize it. Reduce the detail like above, limit your grass density and distance (this fills up ram fast and causes crashes), reduce the number of trees.

That’s about all I can think of. I wish i could say there is one specific secret, but it’s really more about just running your game, watching it crash, reading the error log (which is mostly cryptic to an artist like me but if you just read them you can often see what it was that crashed your game and start there), and reducing the quality.

Oh yeah, goto your QUALITY settings and experiment with 1/8th textures, turning of anisotropy and anti aliasing etc. Start from a really optimized simple scene and move upwards with detail.

Anyways I hope this helps:) I am a huge fan of terrain based 3d and i’m actually surprised we don’t see more of it. The fact that Unity didn’t fix the terrain tree bug for almost a year makes me think that not many people are using terrain and trees on mobile, otherwise it would have been an outcry and high priority. This isn’t to knock Unity but to say that nature designer in games seem to be a bit in the minority.

15 Likes

Awesome, thanks for sharing buddy!

1 Like

Someone asked about making puddles in Unity 5 so I thought I would share the texture im using and the technique from the Viking demo here:

Here’s a quick puddle texture i created. You can save it and import it into unity. Its just a black puddle shape created using a bezier pen in fireworks. Then a glow around the edges (or you could blur it). Added some grunge texture over it, then paintbrushed some textures around the edges. You have to make sure that the texture is also a bit transparent (this is about 95%) because it seems Unity uses the variable transparency when it’s reflecting specular light.

I just inverted it from black to white to make the Albedo texture (basically the diffuse texture) so you can see something when it isnt reflecting. Here that is too:

Create a new material, call it “Puddles” or whatever. Import teh two textures into unity and add them to the material like in the image below. For the Albedo texture i set the Alpha to about 5% and the color to a grey/blue to simluate some almost transparent water.

I added the Puddle Material to decals that drape over the terrain but for a test you can just add the material to a plane.

For your environment, make sure you have a directional light in your scene. I also added a reflection probe to the scene and made sure its bounding box intersected with the puddle. The reflection probe will augment the specular puddle with reflections so you’ll be able to see it better.

And voila - puddles:)

6 Likes

This is Amazing, I am also working on Open World Hunting game, i am not an Artist, level designing is a big problem for me, i tried to contact some artists on Freelancer.com and awarded the project to one of them and lost my $350 :frowning: ,He created some very UGLY looking terrain, no one can create AAA quality terrain for mobile, but only i found you.

1 Like

Thanks for the little tut protopop.

Anybody quoting 350 for triple A quality terrain isn’t going to produce expected results.
High quality terrain like protopop creates is worth several multiples of the money you lost.
Consider ignoring lowest bidders for your next contract and you might find a competent artist to do the work you require.

2 Likes

Thanks for sharing this Protopop !! That’s very helpful.

1 Like

Glad it helps - i love digital wilderness, the more we can all work on them the better:)

are you serious right now??? WOW!

This is beautiful!

This makes me wonder… if my android GPAD 7 is just a pos. (got it from at&t)

With just a flat terrain and one texture, I am still lagging in the frame rate department…

Guess I need to chuck up the 100 bucks and use my iphone 6 plus and see if it really is my android being… a android.

Also, whats the hightmap resolution for your terrains?

Thanks for the resource checker as well…

I was pulling 68mb for textures… now 4mb lmao.

1 Like

Resource checker is awesome:)

I just got the new iPod Touch 6 too and the speed is really good.

My heightmaps are just 256 but the terrain is 2048x2048 meters. The heightmap handles the broad shape of the terrain and the rest is adding in finer details over that like logs, grass etc…

I like Android and i find they can be fast - i bought a nexus phone to test the game and i was running it high speed at 1080p!

Also in my experience the iphones are improvig exponentially each year. A few years ago i could barely run this and now i am positive they will announce Skyrim for iPhone soon:)

I love you puddle idea. I came up with the same exact thing a while back. Found it on accident too xD

I added a texture to the terrain… the terrain system hated how I did the texture in photoshop, and it gave all my dirt paths this really crazy puddle look. Then I was like… huh… this is actually really cool :stuck_out_tongue:

I am flying high in FPS now, thanks to your little article. I am waiting for t4m to update… that should really push the FPS through the roof.

But you’re right on the height map res. We don’t need that much. Trees, grass, logs, rocks, ect… will hide any heightmap detail anyways. So why not lower it and save a little fps :slight_smile:

I keep pushing the limit too. I have not done a 2048x2048 terrain yet. I am at 1000x1000 right now. But I am going to bump it up to 2048x2048 tonight and see how that handles.

I must say, I vowed to never do phone games… but the market is way to large to ignore… and its SUPER fun do to too :slight_smile:

2 Likes

… the hell? You mean… I could make money making terrains/levels for people? Now THAT’S funny! 350 is pretty low. It would take at least 5 working days to get AAA looking level. I mean… fully decked out. Terrain erosion, channels, sediment, water level… just way to much to list.

I am going to that site now :stuck_out_tongue:

Amazing. I have been having a headache using Unity 4.6 on mobile with any terrain loaded with trees and grass while using occlusion culling. Im suspecting you are using Unity 5? It seems to me that Unity 5 has made some major performance improvements for terrain on mobile. Myself and probably everyone included who will read your post are wondering what all your settings are.

Do you atlas your textures and if so do you atlas your trees and grass?

Are your meshes combined if so what program do you use (MeshBaker?)

From the picture posted below the puddels post It looks to me like your terrain is a mesh. If that’s the case then when using terrain composer do you set your trees as objects on the mesh? What is your approch?

What sort of FPS do you achieve?

I found Unity 4.6 was more efficient in many ways. And a HUGE part about working with these kind of open world scenes is the particular version of Unity you are using. For example, Occlusion culling in Unity 4.2 and below ws really, really efficient. I’m currently working with a 4km square terrain, but I had 16km square open world terrains running on the iPhone 4S(!) using it. But Occlusion culling was broken for trees from 4.3 to about 4.5 something so it wouldnt run even on an iPhone 5. When they fixed it i was onto unity 5, which has baked terratin tree shadows broken, so you have to use realtime lighting, so im focusing on metal devices. All this to say you have to be prepared that updates to the engine can possibly break what you can achieve, how you achieve it, and on what devices it will work. It’s happened to me many heart attack inducing times and i try to roll with it:)

The nice thing about Unity 5 is now im working with realtime shadows and global illumination (some screenshots from my iPhone 6 are below). In the upcoming Nimian Legends : BrightRidge HD i’m including a lot of different quality settings. Today there is a huge difference in computing power between say an A5 and an A8X chipset, so you hve to try and gve players away to control their level of quality, and preset certain quality settings by detecting the devices.

Nimian Legends : BrightRidge HD on iPhone 6 - now with realtime shadows!

I don’t atlas my textures, but i wish i had a program that was lightweight and i could easily tell Unity “atlas these” and have it work:) I do try to cut down on quality where it isn’t noticed so much. Tree distances are quite far but billboards are close and i limit the number of trees for example. My trees and grass are each seperate textures (and just from the assets store - there is a ton of beautiful vegetation on there)

No combined meshes but i do make sure to have static and dynamic batching checked. Anything that isn’t moving is static.

My terrain is just a normal unity terrain. I prefer it because it’s easier to make changes and you get all those great terrain benefits like swaying trees and grass. But the puddles are a mesh draped over the terrain and hugging it.

I create my terrain in world machine and export to unity, then use terrain composer to compose logical rules for placing the vegetation and textures. Honestly it think its more trial and error, ive spent literally a few years developing just this landscape , called BrightRidge, alone. And before that there was another full landscape that will probably never be published but took a few years to play with. It’s like clay, just keep adding a few things each week and over time it shapes itself into something that hopefully looks good:)

FPS for the old version was 15 - 30, in the new one it’s about the same depending on the amount of detail. For example the iPad Air 2 is a beast that can handle full and far vegetation and shadows and still have a 25-30fps.

So to sum up i dont use any third party optimizers, just the in unity ones, but i approach it from the start wth a mentality for mobile, shorten distances as much as you can get away with, lower textures but add particles and dust to cover it, just focus on making the illusion that the area is alive without full resolution trees and massive textures. Its like if you’ve ever gone in a museum and sen a diorama - i THINK thats what they are called, just a few stuffed animals, some fake plants and a painted backdrop, but those simple displays fuel the imagination of many visitors by combining a few small things into something greater. It’s all a trick until we can really simulate every atom on some kind of crazy future-computer;)

Nimian Legends : BrightRidge HD on iPhone 6 - now with realtime shadows!

1 Like

Thankyou Protopop for your detailed explanation and sharing with us your fantastic approach for optimization on mobile. The game play pictures look stunningly beautiful and I hope you rock the Appstore with Nimian Legends : BrightRidge.
You have my purchase!!

1 Like

Thanks:) The original is on the app store but i am almost finished the separate HD version and will launch it soon.

One thing i noticed BTW is that when i updated top IOS 8.4 it made some of the trees in my original version flicker blue. Its the first time ive seen an IOS update break a game thats already on the app store so im digging around for my old Unity 4 files to try and update that. Just another thing to be aware of when you release a complicated app:)

1 Like

Show me a screen cap of your messed up trees would you, I’m curious what that looks like :slight_smile:

https://41.media.tumblr.com/bb5ece877da9c69c2cd611632d1a7802/tumblr_nsh2f4A7sg1tkj61lo1_1280.png![](https://41.media.tumblr.com/bb5ece877da9c69c2cd611632d1a7802/tumblr_nsh2f4A7sg1tkj61lo1_1280.png)

It’s only on the conifers, its the blue and it flashes and jumps around. It must be particular to that shader because the other trees are unaffected. It’s not a bog deal and i should be able to fix it with an update, but the point is it’s not the game that’s changed but IOS 8.4 that the game is doing this under. I’m already working to update this older version, and its not in the upcoming HD version but it’s good to be aware that maybe our games might break in future versions of IOS and devices.

It actually just happened with Bioshock:

http://support.2k.com/hc/en-us/articles/206800767-BioShock-Mobile-iOS-Compatibility-Issues

It all plays into the challenge of archiving gameplay for future generations to examine. It’s like try playing an Atari 2600 version of pacman today for research without having an atari 2600 and the cartridge:)

Does it only do that on the billboard?

1 Like

no - only on the mesh tree