Ejemplo n.º 1
0
double octave_noise(const double octaves, const double persistence, const double scale, const double x, const double y, const double z) {
  double total = 0;
  double frequency = scale;
  double amplitude = 1;
  double max_amplitude = 0;

  for (int i = 0; i < octaves; ++i) {
    total += raw_noise(x * frequency, y * frequency, z * frequency) * amplitude;
    frequency *= 2;
    max_amplitude += amplitude;
    amplitude *= persistence;
  }

  return total / max_amplitude;
}
Ejemplo n.º 2
0
// 3D Multi-octave Simplex noise.
//
// For each octave, a higher frequency/lower amplitude function will be added to the original.
// The higher the persistence [0-1], the more of each succeeding octave will be added.
float scaled_octave_noise( const float octaves, const float persistence, const float scale, const float loBound, const float hiBound, const float x, const float y, const float z ) 
{
    float total = 0;
    float frequency = scale;
    float amplitude = 1;

    // Keep track of the largest possible amplitude,
    // because each octave adds more, and we need a value in [-1, 1].
    float maxAmplitude = 0;

    for( int i=0; i < octaves; i++ ) 
	{
        total += raw_noise( x * frequency, y * frequency, z * frequency ) * amplitude;
        frequency *= 2;
        maxAmplitude += amplitude;
        amplitude *= persistence;
    }

    return (total / maxAmplitude) * (hiBound - loBound) / 2 + (hiBound + loBound) / 2;
}
Ejemplo n.º 3
0
double scaled_raw_noise(const double low_bound, const double high_bound, const double x, const double y, const double z) {
  return raw_noise(x, y, z) * (high_bound - low_bound) / 2 +
    (high_bound + low_bound) / 2;
}