56 |
} |
} |
57 |
} |
} |
58 |
int ind = 0; |
int ind = 0; |
59 |
|
|
60 |
|
for(int co = 0; co < components; co++) |
61 |
|
sumsq[co] = sqrt(sumsq[co]); |
62 |
|
|
63 |
for (int j = 0; j < height; j++) { |
for (int j = 0; j < height; j++) { |
64 |
for (int i = 0; i < width; i++) { |
for (int i = 0; i < width; i++) { |
65 |
for(int co = 0; co < components; co++) { |
for(int co = 0; co < components; co++) { |
80 |
FPARAM(freq, 5); |
FPARAM(freq, 5); |
81 |
FPARAM(df, 2); |
FPARAM(df, 2); |
82 |
FPARAM(seed, 0); |
FPARAM(seed, 0); |
83 |
|
FPARAM(turb, 0); |
84 |
|
FPARAM(freq2, 20); |
85 |
|
|
86 |
if (seed) srandom((long)seed); |
if (seed) srandom((long)seed); |
87 |
|
|
88 |
int d = (depth==0 ? 1 : depth); |
int d = (depth==0 ? 1 : depth); |
89 |
|
int n = width*height*d*components; |
90 |
|
|
91 |
|
for(int i = 0; i<n; i++) |
92 |
|
data[i] = 0; |
93 |
|
|
|
for(int i = 0; i<width*height*d*components; i++) |
|
|
data[i] = 0; |
|
94 |
|
|
95 |
fourier_noise(width,height,d,components,data, freq, df); |
if (turb) { |
96 |
for(int i = 0; i<width*height*d*components; i++) { |
float *tmp = new float[n]; |
97 |
data[i] *= scale; |
|
98 |
data[i] += bias; |
for (float f = freq; f <= freq2; f += f) { |
99 |
|
for(int i = 0; i<n; i++) |
100 |
|
tmp[i] = 0; |
101 |
|
fourier_noise(width,height,d,components,tmp, f, df); |
102 |
|
|
103 |
|
float m = 1.0 / (log(f)/log(2) + 1); |
104 |
|
|
105 |
|
for(int i = 0; i<n; i++) |
106 |
|
data[i] += m * fabs(tmp[i]); |
107 |
|
} |
108 |
|
|
109 |
|
for(int i = 0; i<n; i++) |
110 |
|
tmp[i] = 0; |
111 |
|
|
112 |
|
} else { |
113 |
|
|
114 |
|
fourier_noise(width,height,d,components,data, freq, df); |
115 |
|
} |
116 |
|
|
117 |
|
for(int i = 0; i<n; i++) { |
118 |
|
data[i] *= scale; |
119 |
|
data[i] += bias; |
120 |
} |
} |
121 |
} |
} |
122 |
|
|