Created
August 2, 2023 22:46
-
-
Save mattdesl/8be43fdf7beec4e5294a21f57020ae5f to your computer and use it in GitHub Desktop.
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
function fractalNoise(x, y, frequency, octaves, persistence = 0.5, lacunarity = 2) { | |
let total = 0; | |
let amplitude = 1; | |
let maxValue = 0; // Used for normalizing result to 0.0 - 1.0 | |
for (let i = 0; i < octaves; i++) { | |
total += noise2D(x * frequency, y * frequency) * amplitude; | |
maxValue += amplitude; | |
amplitude *= persistence; | |
frequency *= lacunarity; | |
} | |
return total / maxValue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment