Why is Terrain so heavy?!


As a developer of several assets for working with Terrain, I often work with various terrains. Big and small, handcrafted or generated with my own or third party tools. Unity Terrain Engine is a good technology, but I always wondered: why is it so heavy?! One single Terrain can have a size of tens and hundreds of megabytes.

After three years of research and development, I am pleased to introduce Tiny Terrain - Terrain Data compression technology.

What is Tiny Terrain

Tiny Terrain is a lossy Terrain Data compression technology for Unity Terrain Engine, which allows you to reduce the size of the data that Terrain takes in the project many times and significantly reduce the size of your application.

You pay a little CPU time and additional memory usage, but save tens and hundreds of megabytes for each Terrain in the project.

Even though the compression is lossy, in most cases you won't see any visual difference at all.

A very high compression ratio is achieved due to the author's data preparation algorithms and then compression using Brotli. Brotli has a very high compression ratio close to LZMA, fast decoding and very good industry support.

Even if your build or AssetBundle is already compressed using LZ4, LZ4HC or LZMA, Tiny Terrain will be able to reduce its size. Of course the difference in size won't be as huge as with the uncompressed data, but it's still pretty big.

The asset has highly optimized code using direct memory access, which allows for fast decompression and minimizes additional memory usage. On average, one Terrain is loaded in about 1 second.

Synchronous, asynchronous and multi-threaded decompression is supported.

Tiny Terrain is not a 3rd party Terrain Engine, and you can use Unity Terrain API and any terrain tools you like, such as Real World Terrain, Gaia, Vegetation Studio, etc.

How much space can you save

Heightmap. Unity Terrain Engine stores a heightmap of 2 bytes per value. Tiny Terrain compresses this from 2:1 to 20:1 lossless or lossy. In real world elevation data, the compression ratio can be much higher, up to 50:1.

Alphamap. Unity Terrain Engine stores an alphamap in ARGB8 UNorm textures. Tiny Terrain compresses this from 5:1 to 50:1 of its original size lossless or lossy.

Detailmap. Unfortunately, I don't have exact information on how Unity Terrain Engine stores the detailmap, but my observations is that it uses 1 bytes per value. Tiny Terrain compresses this from 5:1 to 50:1 lossless.

Trees. Unity Terrain Engine stores trees 36 bytes per tree. Tiny Terrain removes unused parts of the data, reduces data precision where possible, and only uses 12 bytes per tree, resulting in 3:1 compression ratio.

Holes. Unity Terrain Engine stores holes of 1 byte per value, which adds over 4 MB when used. This is very wasteful. Tiny Terrain compresses holes from 1000:1 to 10000:1 lossless, making them almost weightless. In most cases, the holemap will be less than 1 KB in size.

On average, in real projects, you can expect an overall compression ratio of 3:1 to 50:1 with no visible difference, and up to 100:1 with visible quality loss.

How difficult is it to use

Using Tiny Terrain is very easy, and anyone can do it, even if it is their first day using Unity.

Just add Tiny Terrain Loader component to Terrain and click Compress.

If you are an advanced user or programmer, Tiny Terrain has events and API that will help you take full control of the loading process.

When this asset should be used

Tiny Terrain will be very useful, and sometimes indispensable, in the following cases:

- When minimizing the size of the application is more important than the scene start speed, for example, in mobile or WebGL applications and games;

- When you need to download Terrain from the Internet, for example using the Asset Bundle;

- When you want to load Terrain from any third party source.

Using technology outside of Unity

The heightmap compression feature can be used outside of Unity to compress elevation data such as SRTM.

Tiny Terrain can compress heightmaps lossless, and provide results MUCH compact than HGT+ZIP or MapboxRGB.

It will even be much more compact than HGT compressed using 7Z (LZMA2 with ultra settings).

A big advantage of Tiny Terrain over archived HGT is that decompression and loading happen in single pass, which greatly increases loading speed and reduces memory usage.

The compression and decompression algorithm can be ported to most programming languages, which can make it a universal way to store elevation data.

In addition, it can be easily modified to achieve any vertical accuracy.

Summary + F.A.Q.

How much space can I save?

You will save 65-98% of the original Terrain file size with no visible difference, and up to 99% with visible quality loss.


How fast does Terrain load?

On average, loading takes 1 second per Terrain.


What platforms are supported?

The asset was tested on PC, Mac, Android, iOS, WebGL.

The rest of the platforms have not been tested, but the asset should also work well on them.


Can I use Tiny Terrain with [SOME ASSET]?

Yes, Tiny Terrain is not a 3rd party Terrain Engine, and you can use any asset that works with Unity Terrain Engine, including assets that implement 3rd party Terrain shaders like RTP and GTS.


What Render Pipelines are supported?

Tiny Terrain does not affect rendering, so all Render Pipelines are supported: Built-in RP, URP, HDRP, custom RP.


What versions of Unity Editor are supported?

The asset supports Unity 2021.2 and higher.