// -*-C++-*- #include #define FPARAM(name, default) float name = params->getFloat(#name, default); #define a b static double drand() { return random() / (double)RAND_MAX; } /* Add a fourier noise to the data. */ static void fourier_noise(int width, int height, int depth, int components, float *data, float freq, float df) { int nf = (int)(2 * freq); float xsin[nf][width]; for(int i=0; i freq+df) continue; for(int co = 0; co < components; co++) coeff[co] = drand()-0.5; int ind = 0; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { for(int co = 0; co < components; co++) data[ind++] += xsin[xf][i] * ysin[yf][j] * coeff[co]; } } } } } else { float zsin[width][nf]; // 3D } } void GENERATE(TextureParam *params, int width, int height, int depth, int components, float *data) { FPARAM(bias, 0); FPARAM(scale, 1); FPARAM(freq, 5); FPARAM(df, 2); int d = (depth==0 ? 1 : depth); for(int i = 0; i