Sign in to follow this  
Waaayoff

Storing huge heightmaps?

Recommended Posts

Waaayoff    952
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?

Share this post


Link to post
Share on other sites
Oolala    1102
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.

Share this post


Link to post
Share on other sites
Hodgman    51220
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. Edited by Hodgman

Share this post


Link to post
Share on other sites
6677    1054
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) Edited by 6677

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this