Hacker News new | past | comments | ask | show | jobs | submit login
How to generate random terrain (habrador.com)
95 points by SuperChihuahua on Feb 10, 2013 | hide | past | favorite | 27 comments



If you are interested in a far more terrain like generation, the link casually mentions Diamond-Square at the bottom, but I wrote a post a while back that goes into much deeper detail, after looking at one of Notch's ludum dare entries.

http://www.bluh.org/code-the-diamond-square-algorithm/


If you're interested in this kind of stuff, you might like the paper "A survey of procedural methods for terrain modelling": http://www.cg.its.tudelft.nl/~rafa/myPapers/bidarra.3AMIGAS....


Are there any systems out there that simulate the processes that go into forming real landscapes - geology, volcanoes, glaciation, water flow? [Just to list the main factors determining what I see in the local landscape here in Edinburgh every day - other places will have other factors].


Andrew Price has some amazing tutorials on how to do it with just Blender: http://thenatureacademy.blenderguru.com/sp/7612-the-nature-a...

It is more on modelling rather than generating though.

On procedural generation, we discussed[1] this app written in WebGL: http://creativejs.com/2012/06/snappytree

Other peopled did it with Three.js: http://catchvar.com/threejs-procedurally-generated-infinite-....

And finally, a really lively discussion[2] turned about The Death of the Level Designer: Procedural Content Generation in Games[3]

[1] http://news.ycombinator.com/item?id=4161263

[2] http://news.ycombinator.com/item?id=3872615

[3] http://roguelikedeveloper.blogspot.com/2008/01/death-of-leve...


Yes, there are systems but they aren't anywhere near geared towards real-time because they are basically very large Finite Element Analysis (FEA) problems.

http://en.wikipedia.org/wiki/Geomorphology

For example, OpenSees is used for earthquake modeling.

http://opensees.berkeley.edu/OpenSees/workshops/OpenSeesDays...


You might be interested in Dwarf Fortress. Although it's not exactly what you just asked for, anyone who would phrase a question like that should fire up dwarf fortress at least once.


Terragen 2 - Landscape generator http://planetside.co.uk/index.php?option=com_content&vie...

1st version is free to download


This reminded me all the hours I sunk into playing around with terragen (http://planetside.co.uk/). Definitely remember playing around in photoshop with filters (clouds! and difference clouds!... which I guess is just perlin noise) making height maps.


If you are interested in generating terrains with caves (or other formations with more that just a height detail) then I recommend following this chap http://procworld.blogspot.co.uk/ The technique is based on dual contouring a voxel field and his results are awesome. For info on how he went about it check posts from 2010 (most of it focuses on parallelization using cuda however)


This makes me think of how AoE II generated its maps randomly each time you play. They really had it right. It definitely multiplied the longevity of that game.


I'd wager they had some pre-made pieces that were later slightly modified and stitched together.


One of my earliest memories of "programming" was fucking around with seed files for that map generator. It was very algorithmic, not pre-made.


There's an interesting article at http://accidentalnoise.sourceforge.net/minecraftworlds.html about minecraft-like terrain generation. It uses PolyVox (http://www.volumesoffun.com/polyvox-about/) to do the rendering at the end.


Interesting, i thought minecraft had more complicated algorithms.

Does anyone have any examples on a more specific 2d terrain generation (side-scroller).


Not a side-scroller, but here's a screenshot from a terrain generator that I wrote:

http://i.imgur.com/HgMWbXe.png

the white dot in the center is a control point that the user can drag around. That point defines a mountain. Height decays exponentially with distance from the control point. The height function is perturbed by an underlying noise function.

Edit: It's all done in JS/WebGL using a fragment shader and blatting the output onto static canvas elements. These are then composited for the larger image. It supports scrolling and zooming. I could never get the performance quite to where I wanted it.


And for another example: I wrote a terrain generator for the Abyss in Dungeon Crawl. Since the player is trapped in a hellish Lovecraftian place, the requirements for coherence are much more lax than Minecraft for example.

The algorithm defines some regular (columns, etc) and irregular (random walls) building blocks and then switches between them with Worley noise.

The code is available here: https://gitorious.org/crawl/crawl/blobs/master/crawl-ref/sou...


You can use simple cellular automata to create somewhat natural-looking cave formations: http://rcfox.ca/random-cave-map-generation/


By "set of stairs" do you mean a simple vertical line that cuts trough all of terrain?


Well, I see the image as top-down view of one level in a cave. Going down stairs would mean generating another level.

It's entirely legitimate to see it as a side-view, in which case yes, you'd be cutting through the terrain.


Minecraft also has biomes, which customise the terrain generation to produce regions of a particular type of terrain like forest, desert, sea, etc and some intermediary biome types like beaches. I don't know how it distributes the main biomes, but it may use one noise algorithm for that and another within each biome. Plus applying some rules to handle the borders between biomes. There is a lot more to it that just "It's Perlin noise".


One of my friends from school wrote a paper on a procedural terrain generation method that allowed simple user inputs to control the generation process.

Here's the link: http://larc.unt.edu/ian/research/terrain/


So, what is the difference between value noise and perlin noise?


Perlin noise is a kind of gradient noise. The difference is that, in a value-noise generator, you assign a random value (from some distribution) to each grid point, and then interpolate between the values. In a gradient-noise generator, you assign random gradients to each grid point, and then use dot products to produce the actual values from the gradients.

There's a StackExchange discussion of the subjective differences here: http://math.stackexchange.com/questions/184121/why-is-gradie...


Value noise and Perlin noise are bother coherent noise functions based on integer lattices. Perlin noise is a type of gradient noise.

Value noise defines a pseudrandom value for each lattice point. Intermediate points are determined by interpolating the values of the adjacent lattice points. Value noise has discontinuous derivatives and looks blocky.

Gradient noise defines a pseudo-randomly oriented vector at each lattice point. To find the value of an intermediate point you interpolate the vectors.

If this stuff is interesting, I strongly recommend Texturing & Modeling: A Procedural Approach.


Yea, the blog shows us what Value Noise would produce, and says this is easily confused with Perlin Noise, but does not show us what Perlin Noise output looks like.


Here is a good article showing how to implement perlin noise and its outputs: http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

Also, *yeah.


That's actually not quite Perlin noise either.

In Perlin noise, you set each grid point to a unit gradient vector, and then interpolate between them with a specific equation. This gives it useful mathematical properties, like being continuously differentiable, so the surface normals are smooth when you render it. That's not guaranteed with value noise.

http://webstaff.itn.liu.se/~stegu/TNM022-2005/perlinnoiselin...




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: