This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find unit grid cell containing point | |
var X = Math.floor(x), Y = Math.floor(y), Z = Math.floor(z), W = Math.floor(w); | |
// Get relative xyzw coordinates of point within that cell | |
x = x - X; y = y - Y; z = z - Z; w = w - W; | |
// Wrap the integer cells at 255 (smaller integer period can be introduced here) | |
X = X & 255; Y = Y & 255; Z = Z & 255; w = W & 255; | |
// Calculate noise contributions from each of the SIXTEEN corners | |
// (Just follow the patterns; every unique combination must appear exactly once) | |
var n0000 = gradP[X+ perm[Y+ perm[Z+ perm[W ]]]].dot4(x, y, z, w); |