Last active
January 1, 2016 19:48
-
-
Save tuttlem/8192396 to your computer and use it in GitHub Desktop.
Noise 2
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
float smoothNoise(const float x, const float y) { | |
int ix = (int)x; | |
int iy = (int)y; | |
// sample the corners | |
float corners = (noise(ix - 1, iy - 1) + | |
noise(ix + 1, iy - 1) + | |
noise(ix - 1, iy + 1) + | |
noise(ix + 1, iy + 1)) / 16; | |
// sample the sides | |
float sides = (noise(ix - 1, iy) + | |
noise(ix + 1, iy) + | |
noise(ix, iy - 1) + | |
noise(ix, iy + 1)) / 8; | |
// sample the centre | |
float centre = noise(ix, iy); | |
// send out the accumulated result | |
return corners + sides + centre; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment