Computing the pseudo-random gradient:
|
Computing the gradient must be very fast,
since we must this a number of times
per evaluation of the noise function.
It is also very important
that there be no visible correlations between
successive gradient values in any neighborhood.
Otherwise, telltale correlation patterns will be visible.
In particular, we need to pick our gradients in such a way
that there will be no visible correlation
between the gradient at integer grid point (i,j,k)
and its neighbors at, say, (i+1,j,k), (i,j+1,k) or (i,j,k+1).
Fortunately, it is ok for the noise function to repeat, as long as it repeats only after long distance. After a distance of a few hundred units, it doesn't matter if the same pattern appears again. The noise function has no large-scale features, so by the time an observer is zoomed out far enough to see a repeat pattern, the whole noise texture is too small to see anyway.
Keeping this in mind,
the method I came up with in 1983 for noise over R3 was to
make a solid tiling block 2563 in size.
I did this by precomputing a permutation table P with 256 entries,
which scrambles up the order of the numbers from 0 through 255.
I also precomputed a table of gradients G with 256 entries.
Then I applied the modular arithmetic trick shown on the left.
By alternating between permuting and index addition,
I was able to create a pattern of apparently random
gradients for any input (0,0,0)
|