11 |
/* Add a fourier noise to the data. |
/* Add a fourier noise to the data. |
12 |
*/ |
*/ |
13 |
static void fourier_noise(int width, int height, int depth, int components, float *data, |
static void fourier_noise(int width, int height, int depth, int components, float *data, |
14 |
float freq, float df) { |
float freq, float df, float aniso = 1.0) { |
15 |
int nf = (int)(2 * freq); |
int nf = (int)(2 * (freq + df) * aniso); |
16 |
float xsin[2][nf][width]; |
float xsin[2][nf][width]; |
17 |
for(int i=0; i<width; i++) |
for(int i=0; i<width; i++) |
18 |
for(int f = 0; f < nf; f++) { |
for(int f = 0; f < nf; f++) { |
34 |
for(int xf = 0; xf < nf; xf++) { |
for(int xf = 0; xf < nf; xf++) { |
35 |
for(int yf = 0; yf < nf; yf++) { |
for(int yf = 0; yf < nf; yf++) { |
36 |
|
|
37 |
double f = sqrt(xf*xf + yf*yf); |
double f = sqrt(xf*xf + yf*yf*(aniso*aniso)); |
38 |
if(f < freq-df || f > freq+df) continue; |
if(f < freq-df || f > freq+df) continue; |
39 |
|
|
40 |
for(int xsc = 0; xsc < 2; xsc++) { |
for(int xsc = 0; xsc < 2; xsc++) { |
78 |
FPARAM(bias, 0); |
FPARAM(bias, 0); |
79 |
FPARAM(scale, 1); |
FPARAM(scale, 1); |
80 |
FPARAM(freq, 5); |
FPARAM(freq, 5); |
81 |
|
FPARAM(aniso, 1.0); |
82 |
FPARAM(df, 2); |
FPARAM(df, 2); |
83 |
FPARAM(seed, 0); |
FPARAM(seed, 0); |
84 |
FPARAM(turb, 0); |
FPARAM(turb, 0); |
99 |
for (float f = freq; f <= freq2; f += f) { |
for (float f = freq; f <= freq2; f += f) { |
100 |
for(int i = 0; i<n; i++) |
for(int i = 0; i<n; i++) |
101 |
tmp[i] = 0; |
tmp[i] = 0; |
102 |
fourier_noise(width,height,d,components,tmp, f, df); |
fourier_noise(width,height,d,components,tmp, f, df, aniso); |
103 |
|
|
104 |
float m = 1.0 / (log(f)/log(2) + 1); |
float m = 1.0 / (log(f)/log(2) + 1); |
105 |
|
|
112 |
|
|
113 |
} else { |
} else { |
114 |
|
|
115 |
fourier_noise(width,height,d,components,data, freq, df); |
fourier_noise(width,height,d,components,data, freq, df, aniso); |
116 |
} |
} |
117 |
|
|
118 |
for(int i = 0; i<n; i++) { |
for(int i = 0; i<n; i++) { |