
4.7. Perlin nois e 147
To ch oose a random vector for integer co or d in ate ix we simply look up the table
k=Ntab[ ix mod (N−1)] and use vector k from the list. (As there are only 16
vectors in the table the actual vector used is k&15.)
To choose one of the vectors based on three lattice corner coordin ates , we
can still use a single table by repetition of the look-up three times in succession,
as in:
i d = Ntab [ Ntab [ Ntab [ i x ] + iy ] + i z ] ;
This hash function is chosen because it return s results that are more irregular
than id=Ntab[ix+iy+iz];, for ex amp le.
Note that Ntab has 256 entries whose values lie in the range 0 to 255, so the
sum ...