示例#1
0
FLOAT32 CFrmPerlin::TileableNoise3D(const FLOAT32 x, const FLOAT32 y, const FLOAT32 z, const FLOAT32 w, const FLOAT32 h, const FLOAT32 d)
{
    return ( Noise3D( x,     y,     z     ) * ( w - x ) * ( h - y ) * ( d - z ) +
             Noise3D( x - w, y,     z     ) *       x   * ( h - y ) * ( d - z ) +
             Noise3D( x,     y - h, z     ) * ( w - x ) *       y   * ( d - z ) +
             Noise3D( x - w, y - h, z     ) *       x   *       y   * ( d - z ) + 
             Noise3D( x,     y,     z - d ) * ( w - x ) * ( h - y ) *       z   +
             Noise3D( x - w, y,     z - d ) *       x   * ( h - y ) *       z   +
             Noise3D( x,     y - h, z - d ) * ( w - x ) *       y   *       z   +
             Noise3D( x - w, y - h, z - d ) *       x   *       y   *       z   ) / ( w * h * d );
}
示例#2
0
文件: expfuncs.cpp 项目: OpenDAWN/Syd
ssfloat ExpMgr::Turbulence3D(ssfloat x, ssfloat y, ssfloat z)
{
	ssfloat	turb, s, limit;

	turb = -1.0;
	s = 1;
	limit = 1.0/256;

	while (s > limit) {
		turb += s * Noise3D(x/s,y/s,z/s);
		s /= 2;
	}

	return turb;
}
示例#3
0
FLOAT32 CFrmPerlin::Turbulence3D( const FLOAT32 x, const FLOAT32 y, const FLOAT32 z,
                                  FLOAT32 fFrequency, UINT32 nNumOctaves,
                                  FLOAT32 fAmplitude, FLOAT32 fPersistence )
{
    FLOAT32 fTotal = 0.0f;

    for( UINT32 i=0; i<nNumOctaves; i++ )
    {
        fTotal += Noise3D( fFrequency * x, fFrequency * y, fFrequency * z ) * fAmplitude;
        fFrequency *= 2.0f;
        fAmplitude *= fPersistence;
    }
    
    return fTotal;
}
示例#4
0
			float ValueNoise3D(float x, float y, float z, float amplitude, float wavelength, int octaves, float factor, int seed)
			{
				float sum = 0.0f;
				float range_adjust = 0.0f;
				float temp_amp = 1.0f;

				for(int i = 0; i < octaves; i ++)
				{
					sum += temp_amp * Noise3D(x / wavelength, y / wavelength, z / wavelength, seed);
					wavelength *= factor;
					temp_amp *= factor;
					range_adjust += temp_amp;
				}

				return amplitude * (sum / range_adjust);
			}
示例#5
0
/*
 * Tileable 3D noise
 */
float Noise::TileNoise3D(
    float x, float y, float z, 
    float width, float height, float depth)
{
    float invX = width  - x;
    float invY = height - y;
    float invZ = depth  - z;
    return (
        Noise3D(x,    y,    z)    * invX * invY * invZ +
        Noise3D(invX, y,    z)    * x    * invY * invZ +
        Noise3D(x,    invY, z)    * invX * y    * invZ +
        Noise3D(x,    y,    invZ) * invX * invY * z    +
        Noise3D(invX, invY, z)    * x    * y    * invZ +
        Noise3D(invX, y,    invZ) * x    * invY * z    +
        Noise3D(x,    invY, invZ) * invX * y    * z    +
        Noise3D(invX, invY, invZ) * x    * y    * z
        ) / (width * height * depth);
}
示例#6
0
/*
 * Looping 3D noise
 */
float Noise::LoopNoise3D(float x, float y, float z, float zPeriod)
{
    return ((zPeriod - z) * Noise3D(x,y,z) + 
        z * Noise3D(x, y, zPeriod - z)) / zPeriod;
}
示例#7
0
文件: exeval.c 项目: oleavitt/gem
void eval_noise(Expr *expr)
{
	expr->l->fn(expr->l);
	expr->v.x = Noise3D(&expr->l->v);
}