Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since no one is going to write up an answer from the comments, I'm trying myself. Please upvote when I'm correct, comment when not :)</p> <p>There are several implementations and example code that (try to) implement Perlin noise. First, there is the <a href="http://mrl.nyu.edu/~perlin/noise/" rel="noreferrer">Improved Noise reference implementation</a> from Ken Perlin himself.</p> <h2>Case 1: Improved Noise reference implementation</h2> <p>The noise function takes three double values and outputs a value. When generating a 2D bitmap using x and y, and keeping z constant, one gets the well known Perlin noise pattern. When z is varied between 0.0 and 1.0, the noise clouds seem to "change" slowly. So a seeding method that sets z, e.g. <code>z = 10.0 * seed</code>, could work for "seeding".</p> <p>Another way to seed the noise function would be this: If you always just get noise in a range of [0.0; 64.0[ for x and y, one could seed the noise by adding an offset to x, y or both when calling the noise function: noise(x + 64.0*seed, y + 64.0*seed).</p> <h2>Case 2: Tutorial style Perlin noise code</h2> <p>Then there is an <a href="http://freespace.virgin.net/hugo.elias/models/m_perlin.htm" rel="noreferrer">implementation</a> of Perlin noise (adapted and used in many other Perlin noise tutorials) that have a base noise function like this (pseudocode):</p> <pre><code>function Noise2(integer x, integer y) n = x + y * 57 n = (n&lt;&lt;13) ^ n; return ( 1.0 - ( (n * (n * n * 15731 + 789221) + 1376312589) &amp; 7fffffff) / 1073741824.0); end function </code></pre> <p>My main skepticism came from the magic numbers and the trust of the authors of these pages that the formula leads to uniformly distributed noise. Other authors added the seed value somewhere in this formula.</p> <p>The solution to add a seed to this type of Perlin noise implementation is to write a function that uniformly distributes output values for given x and y values (and by returning the same value for the same x and y values, of course). This function can be written using Boost.Random (code not tested):</p> <pre><code>double Noise2(int x, int y) { uint32_t seeds[3] = { uint32_t(x), uint32_t(y), seed }; boost::mt19937 rng(seeds, seeds+3); boost::uniform_real&lt;&gt; dist(0.0, 1.0); boost::variate_generator&lt;boost::mt19937&amp;, boost::uniform_real&lt;&gt; &gt; die(rng, dist); return die(); } </code></pre> <p>The random number generator has some ctors, among them one that takes a range of uint32_t's that determine the initial state of the RNG.</p> <p>There also are libraries that generate coherent noise, such as <a href="http://libnoise.sourceforge.net/" rel="noreferrer">libnoise</a>, that may be of help here.</p> <h2>Simplex Noise</h2> <p>I didn't ask of Simplex noise, but the one <a href="http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf" rel="noreferrer">implementation (from Stefan Gustavson)</a> I found uses a similar technique (some precomputed tables) like Ken Perlin's reference implementation, and could be seeded just like case 1 above. Commenter Robinson mentioned seeding when generating the look-up table, but I don't know how that would work.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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