Skip to content

Instantly share code, notes, and snippets.

@Gibgezr
Last active November 22, 2016 03:21
Show Gist options
  • Select an option

  • Save Gibgezr/c5b1fb44cbbf826e2032c82d4eb059e7 to your computer and use it in GitHub Desktop.

Select an option

Save Gibgezr/c5b1fb44cbbf826e2032c82d4eb059e7 to your computer and use it in GitHub Desktop.
//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