Created
August 9, 2011 08:14
-
-
Save jsermeno/1133593 to your computer and use it in GitHub Desktop.
Perlin Noise Negative Coordinates
This file contains 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
noise: function (x, y, z) { | |
// Find unit cube that contains point | |
var xFloor = ~~x; | |
var yFloor = ~~y; | |
var zFloor = ~~z; | |
var iX = xFloor & 255; | |
var iY = yFloor & 255; | |
var iZ = zFloor & 255; | |
... |
This file contains 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
noise: function (x, y, z) { | |
// Find unit cube that contains point | |
var xFloor = ~~x; | |
var yFloor = ~~y; | |
var zFloor = ~~z; | |
var iX = xFloor & 255; | |
var iY = yFloor & 255; | |
var iZ = zFloor & 255; | |
// Find relative x, y, z of the point in the cube. | |
x -= xFloor; | |
y -= yFloor; | |
z -= zFloor; | |
if (x < 0) { x += 1; iX = (iX + 255) & 255; } | |
if (y < 0) { y += 1; iY = (iY + 255) & 255; } | |
if (z < 0) { z += 1; iZ = (iZ + 255) & 255; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a full version of this script in Javascript available?