Storing huge heightmaps?

Started by
3 comments, last by 6677 11 years, 10 months ago
My terrain is 30km squared and is represented by a 30000x30000 heightmap. That's ~860MB.. I'm using geometry clipmaps to render the terrain so i also need to store N mipmaps for the heightmap. The paper talks about compressing the terrain and decompressing regions of interest at runtime, but i can't find a free library that does so.

Any thoughts?
"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "
Advertisement
Two points:

1) There are tons of free compression algorithms, but likely not a lot of heightmap-specific ones. You don't likely even need a heightmap specific compression alg, unless "The paper" [which is difficult to speak of in context without knowing what "The paper" is], does something heightmap-specific. You can google for zlib or gzip in just about any sort of configuration/programming language you'd care to name, both of which are general-purpose compression algorithms that are widely known and widely used.

2) Chances are you don't need all 30km^2 of your terrain in memory at a time, and it may be simply a matter of streaming in/out patches of your terrain. Have you considered how much of this environment will be used in worst case during, say, 5 seconds of game play? 1gb of height map on disk may be a price that is easily paid.
Well, it depends on what's faster, opening/reading from a huge file, or decompressing a small one?
"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "
You could store your terrain in a different format - e.g. the vector-lines of a topographic map would compress better than a bitmap height-map. Maybe you could extract contour lines from your source height-map at build-time, and then at run-time use them to rebuild the required portions of the height-map for rendering? Sounds like a bit of work though.
What about having a seperate height map for each square kilometer. What you then do is load a certain number of them into memory at a time in a set radius around the player (lets say a 2 kilometer radius, should cover all scenarios). This is somewhat similar to minecrafts chunk system. You'll still have approximately the same amount of data (unless you use compression aswell) but it will lessen the RAM impact at runtime. There probably isn't a free library to automate this but if your already familiar with loading heightmaps then its probably not a huge stretch to implement this yourself. If the draw distance of your game is greater than the 2 kilometer radius then you could have a second heightmap that covers the entire 30x30 area but is drawn at a MUCH lower resolution (lets say 512x512), if you ensure that the heights on this larger map are slightly lower than the actual heights then any errors (such as valleys too small to appear on the large maps resolution being filled in) would be fixed.


Alternatively, make the heightmap a vector and only rasterize it to a bitmap for a certain radius around the player (in a similar way to above)

This topic is closed to new replies.

Advertisement