News for hackers. Stuff that matters.
Re:Realistic terrain in 130 lines of JavaScript by gavanwoolery on Monday May 12, 2014 @05:10PM (#7735433)
Just a small note, not to sound snooty, just to educate people on what realistic terrain looks like...

This is what midpoint displacement looks like as a heightmap: http://imgur.com/ksETpO0,7gykFEV#0 This is what realistic terrain looks like (this is based on real-world heightmap data): http://imgur.com/ksETpO0,7gykFEV#1

That said, midpoint displacement, perlin/simplex noise, etc are good for modeling terrain at a less macroscopic scale and are plenty sufficient for the use of most games.

Re:Realistic terrain in 130 lines of JavaScript by gavanwoolery on Monday May 12, 2014 @05:13PM (#7735444)
To add another note, as complex as real world terrain is, you can generate those fractal mountain patterns and drainage basins algorithmically with a bit of work. There are many ways to go about it, one would be recursive spacial partitioning, another would be to explicitly grow out a tree pattern while minding collision and proximity to other branches. Also, it is possible to use diffusion limited aggregation or erosion simulation but I have been down both those routes and they are not as easy to get good results with.
Re:Realistic terrain in 130 lines of JavaScript by mjn on Monday May 12, 2014 @05:29PM (#7735515)
Further reading:

1. A semi-standard textbook on the subject, but now a bit dated (don't be fooled by the 2002 date on the 3rd ed., most of the text is from the 1st ed): http://www.amazon.com/Texturing-Modeling-Third-Edition-Proce...

2. A more recent but much shorter survey paper: http://graphics.tudelft.nl/Publications-new/2009/SDGTB09a/SD...

Re:Realistic terrain in 130 lines of JavaScript by hunterloftis on Monday May 12, 2014 @05:47PM (#7735600)
Thanks for this! I've been looking for resources on building out lifelike macro-terrain-structures.
Re:Realistic terrain in 130 lines of JavaScript by userbinator on Monday May 12, 2014 @05:51PM (#7735616)
Reminds me of this - pretty good looking terrain + animation + sound in a 4 kilobyte executable:

http://www.youtube.com/watch?v=_YWMGuh15nE

How it was done:

http://iquilezles.org/www/material/function2009/function2009...

Re:Realistic terrain in 130 lines of JavaScript by ohwp on Tuesday May 13, 2014 @03:12AM (#7736864)
I like this one even more because it is procedural. No height map needed.
Re:Realistic terrain in 130 lines of JavaScript by Arelius on Tuesday May 13, 2014 @12:29PM (#7738979)
Thank you... What people don't realize is that "Random Noise" doesn't actually occur that often in real terrain. The bump tool in game engines is the bain of realistic terrain everywhere.

This: http://i.imgur.com/DFXMmY8.jpg doesn't generally happen in nature.

Re:Realistic terrain in 130 lines of JavaScript by tripzilch on Tuesday May 13, 2014 @06:15AM (#7737366)
Interesting. Those branchy ridge shapes look a lot like Diffusion-Limited Aggregate patterns. But then, I guess they didn't call it "universality" for nothing :)

They also reminded me a bit of GIMP's "Solid Noise" rendering with the "Turbulence" setting switched on. I rendered one, and turns out it doesn't quite look as good (cough), but now I wonder whether this would give a bit more realistic height map: http://imgur.com/oRlZ191

On the other hand, like you say, for terrains for videogames are always best generated by taking any of these algorithms, and mercilessly tweaking the parameters, post-processing, etc until it just looks sufficiently good. Actual physical realism comes into second place (and it should, like most game physics).

Re:Realistic terrain in 130 lines of JavaScript by IceCreamYou on Tuesday May 13, 2014 @06:53AM (#7737465)
I've been working on a WebGL terrain engine recently -- you can try it out and switch on the "Turbulent" flag to see the results :)

https://icecreamyou.github.io/THREE.Terrain/

Re:Realistic terrain in 130 lines of JavaScript by gavanwoolery on Tuesday May 13, 2014 @06:05PM (#7740955)
Using a noise function I produced similar turbulence once. Here was my result (it does, IMHO, look a bit better than vanilla noise):

http://www.gavanw.com/uploads/9/5/4/0/9540564/4868178_orig.p...

Re:Realistic terrain in 130 lines of JavaScript by pertsix on Tuesday May 13, 2014 @01:21AM (#7736674)
Is this the same algorithm for the cloud filter from Adobe Photoshop?
Re:Realistic terrain in 130 lines of JavaScript by gavanwoolery on Tuesday May 13, 2014 @01:48AM (#7736713)
I believe photoshop uses Perlin noise (could be wrong)
Re:Realistic terrain in 130 lines of JavaScript by signa11 on Tuesday May 13, 2014 @02:34AM (#7736773)
this looks more like perlin noise to me...
Re:Realistic terrain in 130 lines of JavaScript by jayrobin on Tuesday May 13, 2014 @06:27AM (#7737401)
I agree it looks more like Perlin noise due to the finer detail not seen in diamond square [1] and the lack of directional artifacts in midpoint displacement [2].

[1] http://www.gameprogrammer.com/fractal/heightmap.jpg

[2] http://upload.wikimedia.org/wikipedia/en/9/96/Plasmafractal....