Skip to content

Instantly share code, notes, and snippets.

@tuttlem
Last active January 1, 2016 19:48
Show Gist options
  • Save tuttlem/8192396 to your computer and use it in GitHub Desktop.
Save tuttlem/8192396 to your computer and use it in GitHub Desktop.
Noise 2
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