Code Request: Heightmap generator

Hi folks,

Some of you know about the project I’m working on and right now I’m trying to see if anyone out there can shave some time off my development by sharing a heightmap generator. I don’t particularly need it for a 3D scene since I’m looking to wrap these textures around spheres (for planets) so the only thing I’m trying to do is make sure there are no seems.

To date I’ve been trying to use Bryce and similar to produce these maps and while that’s nice for putting together one-zee two-zee types, I need to be able to generate hundreds of planet textures - so if anyone has that or a pointer to some, lemme know.

Thanks!

This may sound silly but what’s wrong with Math.random() and a little convolution filter to smooth things out a bit?

Failing that I’ve got some Perlin noise code in the SPGL somewhere I used for my terrain demo thing.

Cas :slight_smile:

I have the following heightmap generators, one using Midpoint displacement, one using Fault Fractal, and one using Particle disposition. I also have a combiner that allows the + - * of multiple heightmaps. Let me know if that interests you

see http://www.mojomonkeycoding.com/images/jme/HeightMaps.jpg
and
http://www.mojomonkeycoding.com/images/jme/Combiner.jpg
for a screenshot of the results.

And math random is a poor choice because it is far too chaotic to look natural, even after filtering. You’d never get smooth mountains and hills with pure random.

I wrote a hydraulic erosion simulation a while back… Basically, it starts off with a plain midpoint displacement map (what wurm currently uses, btw), adds water to all nodes, then lets the water run downhill while transporting some “mass” (height).

http://www.theintraclinic.com/erode.gif

I’d rather not post the code as I never really did get it to work properly. :wink:

post it…post it…my attempts at erosion bite…I would be very interested

Hm, I looked around for a while, and it seems the finished erosion classes missed my (infrequent) backups, so they’re lost in the bitbucket.

However, a class called “Erosion” is still included in the wurm source (that we now have a proper cvs for), and upon closer examination, that turned out to be one of the first versions of it. It’s wrong in a lot of ways (I even think it explodes instead of going stable), and there’s no actual ERODING in it yet, but here you go: Eroder.java
(Yes, I renamed it. And it’s not commented. And actually not as ugly as it could be)

Basically, you want to move some data from the ground ValueMap into the dissolved one unless dissolved/water exceed a certain threshold. If it does, move it the other way instead.
Then make the moveWater method move some dissolved ground as well as water (in pretty much the same way), add rain and evaporation, and run it for a few thousand passes.

Oh, and make sure you never end up with negative values of ground, dissolved or water. That’s a Bad Thing.

Got few things for ya

http://www.realityflux.com/abba/heightmap.jpg

Displacement map done in software

[quote]This may sound silly but what’s wrong with Math.random() and a little convolution filter to smooth things out a bit?

Failing that I’ve got some Perlin noise code in the SPGL somewhere I used for my terrain demo thing.

Cas :slight_smile:
[/quote]
Unfortunately planets don’t look that random. I’m looking some something that generates relatively ‘natural’ heightmaps. The Bryce folks had gotten pretty good at coming up with algos for that - but their work is not publicly available.

Well, try that Perlin noise generator in SPGL. It’s fairly simple. Perlin noise can be tweaked in various ways to make it look different.

Cas :slight_smile:

Aye, layered perlin noise does work well for natural looking heightmaps. The best way i’ve found is in a kinda fractal way - take several layers of perlin noise with increasing frequency and blend them together with decreasing weights.

The weights and layers tend to need some careful tweeking, but i’ve found that 3 or 4 layers is all thats needed. Other than that you can get some ideas from the paper Ken Perlin wrote on it. Things like the crease from adding sin etc. seem to work well for underwater / low errosion landscapes.