Created
August 2, 2023 22:46
-
-
Save mattdesl/8be43fdf7beec4e5294a21f57020ae5f to your computer and use it in GitHub Desktop.
Revisions
-
mattdesl created this gist
Aug 2, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ 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; }