Exemple #1
0
/**
 * This is a similar function to the main perlin noise calculation, but uses
 * the value p passed as a parameter rather than selected from the predefined
 * sequences. as you can guess by its title, i use this to create the indented
 * coastline, which is just another perlin sequence.
 */
static double perlin_coast_noise_2D(const double x, const double y, const double p, const int prime)
{
	double total = 0.0;

	for (int i = 0; i < 6; i++) {
		const double frequency = (double)(1 << i);
		const double amplitude = pow(p, (double)i);

		total += interpolated_noise((x * frequency) / 64.0, (y * frequency) / 64.0, prime) * amplitude;
	}

	return total;
}
Exemple #2
0
float Perlin2D(float x, float y, float persistence, int n_octave)
{
	float total = 0;
	float p = persistence;
	
	int i;
	for(i = 0; i < n_octave; i++) {
		
		float freq = pow(2, i);
		float ampl = pow(p, i);
		
		total += interpolated_noise(x * freq, y * freq) * ampl;
	}
	
	return total;
}