14 float p,
const float detail,
const float roughness,
const float lacunarity,
bool normalize)
28 const float rmd = detail -
floorf(detail);
31 const float sum2 =
sum + t * amp;
32 return normalize ?
mix(0.5f *
sum / maxamp + 0.5f, 0.5f * sum2 / (maxamp + amp) + 0.5f, rmd) :
39 float2 p,
const float detail,
const float roughness,
const float lacunarity,
bool normalize)
53 const float rmd = detail -
floorf(detail);
56 const float sum2 =
sum + t * amp;
57 return normalize ?
mix(0.5f *
sum / maxamp + 0.5f, 0.5f * sum2 / (maxamp + amp) + 0.5f, rmd) :
64 float3 p,
const float detail,
const float roughness,
const float lacunarity,
bool normalize)
78 const float rmd = detail -
floorf(detail);
81 const float sum2 =
sum + t * amp;
82 return normalize ?
mix(0.5f *
sum / maxamp + 0.5f, 0.5f * sum2 / (maxamp + amp) + 0.5f, rmd) :
89 float4 p,
const float detail,
const float roughness,
const float lacunarity,
bool normalize)
101 fscale *= lacunarity;
103 const float rmd = detail -
floorf(detail);
106 const float sum2 =
sum + t * amp;
107 return normalize ?
mix(0.5f *
sum / maxamp + 0.5f, 0.5f * sum2 / (maxamp + amp) + 0.5f, rmd) :
117 const float roughness,
118 const float lacunarity)
129 const float rmd = detail -
floorf(detail);
131 value *= (rmd * pwr *
snoise_1d(p) + 1.0f);
139 const float roughness,
140 const float lacunarity)
151 const float rmd = detail -
floorf(detail);
153 value *= (rmd * pwr *
snoise_2d(p) + 1.0f);
161 const float roughness,
162 const float lacunarity)
173 const float rmd = detail -
floorf(detail);
175 value *= (rmd * pwr *
snoise_3d(p) + 1.0f);
183 const float roughness,
184 const float lacunarity)
195 const float rmd = detail -
floorf(detail);
197 value *= (rmd * pwr *
snoise_4d(p) + 1.0f);
206 float p,
const float detail,
const float roughness,
const float lacunarity,
const float offset)
208 float pwr = roughness;
215 const float increment = (
snoise_1d(p) + offset) * pwr * value;
221 const float rmd = detail -
floorf(detail);
223 const float increment = (
snoise_1d(p) + offset) * pwr * value;
224 value += rmd * increment;
232 const float roughness,
233 const float lacunarity,
236 float pwr = roughness;
243 const float increment = (
snoise_2d(p) + offset) * pwr * value;
249 const float rmd = detail -
floorf(detail);
251 const float increment = (
snoise_2d(p) + offset) * pwr * value;
252 value += rmd * increment;
260 const float roughness,
261 const float lacunarity,
264 float pwr = roughness;
271 const float increment = (
snoise_3d(p) + offset) * pwr * value;
277 const float rmd = detail -
floorf(detail);
279 const float increment = (
snoise_3d(p) + offset) * pwr * value;
280 value += rmd * increment;
288 const float roughness,
289 const float lacunarity,
292 float pwr = roughness;
299 const float increment = (
snoise_4d(p) + offset) * pwr * value;
305 const float rmd = detail -
floorf(detail);
307 const float increment = (
snoise_4d(p) + offset) * pwr * value;
308 value += rmd * increment;
318 const float roughness,
319 const float lacunarity,
327 for (
int i = 0; (weight > 0.001f) && (
i <=
float_to_int(detail));
i++) {
328 weight =
fminf(weight, 1.0f);
330 const float signal = (
snoise_1d(p) + offset) * pwr;
332 value += weight * signal;
333 weight *= gain * signal;
337 const float rmd = detail -
floorf(detail);
338 if ((rmd != 0.0f) && (weight > 0.001f)) {
339 weight =
fminf(weight, 1.0f);
340 const float signal = (
snoise_1d(p) + offset) * pwr;
341 value += rmd * weight * signal;
349 const float roughness,
350 const float lacunarity,
358 for (
int i = 0; (weight > 0.001f) && (
i <=
float_to_int(detail));
i++) {
359 weight =
fminf(weight, 1.0f);
361 const float signal = (
snoise_2d(p) + offset) * pwr;
363 value += weight * signal;
364 weight *= gain * signal;
368 const float rmd = detail -
floorf(detail);
369 if ((rmd != 0.0f) && (weight > 0.001f)) {
370 weight =
fminf(weight, 1.0f);
371 const float signal = (
snoise_2d(p) + offset) * pwr;
372 value += rmd * weight * signal;
380 const float roughness,
381 const float lacunarity,
389 for (
int i = 0; (weight > 0.001f) && (
i <=
float_to_int(detail));
i++) {
390 weight =
fminf(weight, 1.0f);
392 const float signal = (
snoise_3d(p) + offset) * pwr;
394 value += weight * signal;
395 weight *= gain * signal;
399 const float rmd = detail -
floorf(detail);
400 if ((rmd != 0.0f) && (weight > 0.001f)) {
401 weight =
fminf(weight, 1.0f);
402 const float signal = (
snoise_3d(p) + offset) * pwr;
403 value += rmd * weight * signal;
411 const float roughness,
412 const float lacunarity,
420 for (
int i = 0; (weight > 0.001f) && (
i <=
float_to_int(detail));
i++) {
421 weight =
fminf(weight, 1.0f);
423 const float signal = (
snoise_4d(p) + offset) * pwr;
425 value += weight * signal;
426 weight *= gain * signal;
430 const float rmd = detail -
floorf(detail);
431 if ((rmd != 0.0f) && (weight > 0.001f)) {
432 weight =
fminf(weight, 1.0f);
433 const float signal = (
snoise_4d(p) + offset) * pwr;
434 value += rmd * weight * signal;
444 const float roughness,
445 const float lacunarity,
449 float pwr = roughness;
453 float value = signal;
462 value += signal * pwr;
471 const float roughness,
472 const float lacunarity,
476 float pwr = roughness;
480 float value = signal;
489 value += signal * pwr;
498 const float roughness,
499 const float lacunarity,
503 float pwr = roughness;
507 float value = signal;
516 value += signal * pwr;
525 const float roughness,
526 const float lacunarity,
530 float pwr = roughness;
534 float value = signal;
543 value += signal * pwr;
static T sum(const btAlignedObjectArray< T > &items)
#define ccl_device_noinline
#define CCL_NAMESPACE_END
ccl_device_noinline float noise_hetero_terrain(float p, const float detail, const float roughness, const float lacunarity, const float offset)
CCL_NAMESPACE_BEGIN ccl_device_noinline float noise_fbm(float p, const float detail, const float roughness, const float lacunarity, bool normalize)
ccl_device_noinline float noise_ridged_multi_fractal(float p, const float detail, const float roughness, const float lacunarity, const float offset, const float gain)
ccl_device_noinline float noise_multi_fractal(float p, const float detail, const float roughness, const float lacunarity)
ccl_device_noinline float noise_hybrid_multi_fractal(float p, const float detail, const float roughness, const float lacunarity, const float offset, const float gain)
VecBase< float, D > normalize(VecOp< float, D >) RET
ccl_device_inline int float_to_int(const float f)
ccl_device_inline float snoise_1d(float p)
ccl_device_inline float snoise_2d(float2 p)
ccl_device_inline float snoise_3d(float3 p)
ccl_device_inline float snoise_4d(float4 p)