Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A friend just linked me to this question, and I thought I'd try and clear up a couple things that aren't addressed in the accepted answer.</p> <p>Elias' interesting and helpful article uses "value noise" not "Perlin noise". Value noise involves curve-fitting of randomized points. Gradient noise (of which Perlin noise is a primary example) creates a lattice of 0-value points and gives each one a random gradient. They are frequently confused with one another!</p> <p><a href="http://en.wikipedia.org/wiki/Gradient_noise" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Gradient_noise</a></p> <p>Secondly, using a 3rd value as a seed is expensive. If you want random terrain, consider translating your origin a random amount instead. 3D calls are going to be more expensive than 2D calls. And all you are doing is using the z value to select a particular slice of 2D noise.</p> <p>Thirdly, the straight function call is going to return values that are fairly smooth and rolling overall, not as craggy as real terrain, since it's randomness is limited to a single frequency. To get craggier terrain, a good technique is to sum together multiple calls that progress through the noise space at differing frequencies, usually set a "fractal" values. </p> <p>Thus, for example, sum together <code>noise(x, y) + (1/2)(noise(x*2, y*2) + (1/4)(noise(x*4, y*4)</code>...</p> <p>The resulting sum will probably often be outside the range -1 to 1, so you will have to normalize the result before the values are useful. I'd like to suggest setting up the factor series (1, 1/2, 1/4, etc.) so that you are guaranteed to remain within [-1, 1] which can be done by progressive weighting depending upon how many 'octaves' you use. (But I don't know if this is truly the most efficient way to do this.)</p> <p>Example with four octaves: <code>(1/15)(noise(x, y) + (2/15)(noise(2x, 2y) + (4/15)(noise(4x, 4y) + (8/15)(noise(8x, 8y)</code></p> <p>Then, use the "turbulent noise" normalization of taking the sum and making it <code>= |sum|</code> (i.e., using the abs function). This will give the terrain definite angular valley ridges as opposed to being smoothly rolling.</p> <p>I'm working on a SimplexNoise visualizer, hope to open source it on GitHub eventually, as a Java project. A first draft of the visualizer can be found and run via this post at java-gaming.org: <a href="http://www.java-gaming.org/topics/simplex-noise-experiments-towards-procedural-generation/27163/view.html" rel="nofollow noreferrer">http://www.java-gaming.org/topics/simplex-noise-experiments-towards-procedural-generation/27163/view.html</a> The emphasis on the first draft is more tutorial, with generated code examples (but they are in Java).</p> <p>Great article on how SimplexNoise works (and Perlin vs Gradient background): <a href="http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf" rel="nofollow noreferrer">http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf</a></p> <p>Stefan Gustavson did a really nice job of this!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload