Example #1
0
	double PerlinNoise2D(double x, double y){
		double total = 0, frequency = 1, amplitude = 1;
		for (int i = 0; i < 4; i++){
			total += InterpolatedNoise(x*frequency, y*frequency)*amplitude;
			frequency *= 2;
			amplitude /= 2;
		}
		return total;
	}
Example #2
0
float PerlinNoise::Perlin(float x, float y)
{
    float total = 0;
    for(int i=0; i<m_iOctaves; i++)
    {
        float freq = pow(2, i);
        float amp = pow(m_fPersistance, i);

        total += InterpolatedNoise(x*freq/m_fZoom, y*freq/m_fZoom, i) * amp;
    }
    return total;
}
Example #3
0
	float PerlinNoise2D(float x, float y){
		float total, frequency, amplitude, a;
		int i, n;
		total = 0;
		n = 8;
		for (i = 0; i <= n; i++){
			frequency = (float)pow(2, i);
			amplitude = (float)pow(0.5, i);
			a = InterpolatedNoise(x*frequency, y*frequency)*amplitude;
			total += a;
		}
		return total;
	}
Example #4
0
float PerlinNoise::GetNoise( float x )
{
    float Total = 0.0;
    
    for( unsigned int i = 0; i < n; ++i )
    {
        int Freqency = 1<<i; // 2^i
        float Amplitude = pow( p, i );
        
        Total += InterpolatedNoise( x * Freqency ) * Amplitude;
    }
    
    return Total;
}
Example #5
0
PerlinNoise::PerlinNoise()
{
	for (int x = 0; x < 256;x++)
		for (int y = 0; y < 256;y++)
			noise_lq[x][y] = noise(x , y);

	for (int x = 0; x < 32;x++)
		for (int y = 0; y < 32;y++)
			noise_lq_lite[x][y] = noise(4*x,16*y);

	for (int x = 0; x < 256;x++)
		for (int y = 0; y < 256;y++)
			noise_mq[x][y] = InterpolatedNoise((float)x/(float)2.0,(float)y/(float)2.0);

	for (int x = 0; x < 256;x++)
		for (int y = 0; y < 256;y++)
			noise_hq[x][y] = InterpolatedNoise((float)x/(float)3.0,(float)y/(float)3.0);

	for (int x = 0; x < 32;x++)
		for (int y = 0; y < 32;y++)
			for (int z = 0; z < 32;z++)
				noise_lq_vol[x][y][z] = noise(x,y,z);

	for (int x = 0; x < 32;x++)
		for (int y = 0; y < 32;y++)
			for (int z = 0; z < 32;z++)
				noise_hq_vol[x][y][z] = noise(x,y,z);//perlin_noise_3d(x,y,z,6121,7,seed3,0.5,64);

	int seed = rand()%1000;

	int size = 512;
	int octaves = sqrt(size);

		for (int x = 0; x < size;x++)
			for (int y = 0; y < size;y++)
				noise_perlin[x][y] = perlin_noise_2d(x,y,6321,octaves,seed,0.5,size/4);
}
Example #6
0
float CSulPerlinNoise2D::PerlinNoise( float x, float y )
{
	float total = 0.0f;

	sigma::uint32 i;
	for ( i=0; i<m_iOctaves; i++ )
	{
		float frequency = pow( 2.0f,(sigma::int32)i );
		float amplitude = pow( m_fPersistence,(sigma::int32)i );

		total = total + InterpolatedNoise( x*frequency, y*frequency, frequency ) * amplitude;
	}
	
	return total;
}
Example #7
0
float PerlinNoise_1D(float x) {
	float p = 0.2f;
	int octaves = 6;

	unsigned int frequency = 1;
	float amplitude = 1;
	
	float total = 0;
	for(int i = 1; i < octaves; i++) {

		total += InterpolatedNoise(x * frequency) * amplitude;
		frequency <<= 1;
		amplitude *= p;
	}

	return total;
}
 float PerlinNoise_2D(float x, float y)
 {
      float total = 0;
      float p = (1.0/2.0) ;
      int n = 6 - 1;
	  int i;

     
   	for(i=0;i<=n;i++)
	{

         float frequency = pow(2.0,i);
         float amplitude = pow(p,i);

         total = total + InterpolatedNoise(x * frequency, y * frequency) * amplitude;

	}

      return total;

 }