Entalpi
Entalpi

Reputation: 2033

How to use index to derive pseudorandom gradient in 2D simplex noise

When using simplex noise one of it's main features is in the generation of gradients on-the-fly. This algorithm is described here. The problem is that even in the patent the gradient generation algorithm is only described in three dimensions (see below).

The specific new technique is as follows: The six bit index is split into (i) a lower three bit quantity, which is used to compute a magnitude of either zero or one for each of x,y and z, and (ii) an upper three bit quantity, which is used to determine an octant for the resulting gradient (positive or negative sign in each of x,y, and z).

If bit1bit0=0, then let (p,q,r)=(x,y,z). Otherwise, let (p,q,r) be a rotation of the order of (x,y,z) to (y,z,x) or (z,x,y), as bit1bit0=1 or 2, respectively, and set either q or r to zero as bit2=0 or 1, respectively.

000 p = x q = y r = z
001 p = y q = z r = 0
010 p = z q = x r = 0
011 p = x q = y r = 0
100 p = x q = y r = z
101 p = y q = 0 r = x
110 p = z q = 0 r = y
111 p = x q = 0 r = z

Then you basically continue and flip the signs of the components of the generated gradient.

The problem is basically how does the above rotation algorithm translate to 2D?

Upvotes: 0

Views: 57

Answers (0)

Related Questions