コード例 #1
0
ファイル: tgp.cpp プロジェクト: M3Henry/openttd
/**
 * 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;
}
コード例 #2
0
ファイル: test_image.c プロジェクト: KelseyGeiger/PPM-Render
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;
}