Hope this is the right place - optimal map size and managing multiple maps

If I am asking in the wrong place, just let me know, and I’ll go there, still finding my feet. Anyhow, I am learning C#, and for a fun sort of learning project I thought I would grab some publicly available terrain data. With this data, I’d do some math stuff and get a bitmap out of it, for importing into Unity as a terrain heightmap.

The data source I am coding against provides square maps, 20 kilometers on a side, but it looks like Unity’s default map size is 2km on a side. Can Unity handle a map that is 400km2 instead of just 4? There would be water, as well as an abundance of trees in some areas.

I plan on using occlusion culling, and possibly a dynamic draw distance if possible to make things easy on the client if that makes a difference.

So far, I have found good data for all of the UK, and i another format, the GIS data for most of the USA, but not all in one place. Stitching maps will be relatively easy, as I can reference edge points from a previous map when setting up a new map… but I would like to know how best to handle possibly hundreds of small maps if that’s the best option.

with a terrain of that size you won’t be using occlusion culling for granted, it will not build anymore.

So, 20km is way too big? I can cut it down in size, what are the upper bounds then?

Do you have to be able to see all of the terrain at once (like from space), or could it be split into smaller sections?

There are two factors, size and resolution. Size is arbitrary and can be whatever you like, and doesn’t have as much impact on performance (actually, larger terrains tend to have better performance, because there’s less detail nearby to render). Resolution is how detailed the terrain is, has more of an impact on performance, and must be power of two plus one. Theoretically the maximum is 4097x4097, but due to a bug, 2049x2049 is the highest you can have hassle-free. Naturally, spreading 2049x2049 over 400 square km is quite coarse, so you’d probably want to have a number of separate terrains.

–Eric

I am trying to build a RTS, so my overall detail level can be lower, I am thinking of limiting it to 2km on a side, and have each battle as an instance on a map. Maybe do the more abstract planning on a scale map 1 to 100 or something.

From what I understand, the heightmap size of the terrain is one of the biggest limiting factors, is this true?
So, let’s say he created a 2048x2048 terrain. If each pixel was 1 meter, then that’s a 2km by 2km world. If he scaled the terrain by 4, that would give him an 8km x 8km terrain…granted, the overall landscape won’t allow as much detail. I guess it depends…if he wants a map that is both big AND detailed he maybe out of luck.
Or am I totally mistaken on that?

You are correct. Since the max supported hassle free height map is 2048x2048, scaling to 8kx8k instead of 2kx2k would have a significant effect on quality. Say the 2048x2048 pixels map 1 pixel per 1 square meter for a 2kx2k map. So multiplying the size of the map by 4 to 8kx8k would effectively make each pixel control 4 square meters instead of 1 square meter, thus never allowing you to have control on anything under 4 square meters.

Big and detailed means you need to have multiple terrains and use the Terrain.SetNeighbors() functions for the terrains surrounding the area to ensure proper LOD.
See: http://unity3d.com/support/documentation/ScriptReference/Terrain.SetNeighbors.html

My heightmap file is, at the moment, 10% done, and weighing in at 70MB, before converting to RAW. It looks like I will be using the Terrain.SetNeighbours, and splitting my 20km maps down to 2km even, so 100 maps from one file. Wow.

I want to stick to 1 pixel = 1 square meter, and stay with whole numbers, so if I do a height map of 2000x2000, and keep my terrain size at 2000x2000, that should give me a lot of good detail. It will also allow me to be more precise with my heightmap, as across 200 square kilometers, I can have a height difference bigger than an 8 bit integer would allow for 1 meter difference between two shades of gray, but over four square kilometers, I don’t think I will.

Oh well, at least I am learning some good programming stuff.

You can’t; heightmaps must be power of two plus one. It will have to be 2049x2049.

–Eric

Well drat. I guess I would have found out eventually. Just need to change a few variables then.

EDIT: I forgot you said you were working on an RTS, so this post doesn’t really apply. I will leave it here for others that are making any other kind of game.

When using so many terrains connected together, I would highly recommend that you use some occlusion culling areas:
http://unity3d.com/support/documentation/Manual/Occlusion Culling.html

Also you can avoid loading all terrains at once and load the necessary ones when needed. This can be done using asset bundles(Pro Only) or Resources.Load(). Resources.Load() is for local game content only. Streaming content across the net is what asset bundles are for.

Asset Bundles: (Pro Only)
http://unity3d.com/support/documentation/Manual/Loading%20Resources%20at%20Runtime.html

Resources.Load()