Last active
November 22, 2016 03:21
-
-
Save Gibgezr/c5b1fb44cbbf826e2032c82d4eb059e7 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
| //try values for persistance like 0.75 - 0.25 | |
| public double OctavePerlin(double x, double y, double z, int octaves, double persistence) | |
| { | |
| double total = 0; | |
| double frequency = 1; | |
| double amplitude = 1; | |
| double maxValue = 0; // Used for normalizing result to 0.0 - 1.0 | |
| for(int i=0;i<octaves;i++) | |
| { | |
| total += perlin(x * frequency, y * frequency, z * frequency) * amplitude; | |
| maxValue += amplitude; | |
| amplitude *= persistence; | |
| frequency *= 2; | |
| } | |
| return total/maxValue; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment