BRL-CAD
noise.c
Go to the documentation of this file.
1 /* N O I S E . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2004-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 
21 /** @addtogroup noise */
22 /** @{ */
23 /** @file libbn/noise.c
24  *
25  * These noise functions provide mostly random noise at the integer
26  * lattice points. The functions should be evaluated at non-integer
27  * locations for their nature to be realized.
28  *
29  * Contains contributed code from:
30  * F. Kenton Musgrave
31  * Robert Skinner
32  *
33  */
34 
35 #include "common.h"
36 
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <math.h>
40 #include "bu/log.h"
41 #include "bu/malloc.h"
42 #include "bu/parallel.h"
43 #include "vmath.h"
44 #include "bn/noise.h"
45 #include "bn/rand.h"
46 
47 
48 /**
49  * @brief interpolate smoothly from 0 .. 1
50  *
51  * SMOOTHSTEP() takes a value in the range [0:1] and provides a number
52  * in the same range indicating the amount of (a) present in a smooth
53  * interpolation transition between (a) and (b)
54  */
55 #define SMOOTHSTEP(x) ((x) * (x) * (3 - 2*(x)))
56 
57 
58 /**
59  * @brief
60  * fold space to extend the domain over which we can take noise
61  * values.
62  *
63  *@n x, y, z are set to the noise space location for the source point.
64  *@n ix, iy, iz are the integer lattice point (integer portion of x, y, z)
65  *@n fx, fy, fz are the fractional lattice distances above ix, iy, iz
66  *
67  * The noise function has a finite domain, which can be exceeded when
68  * using fractal textures with very high frequencies. This routine is
69  * designed to extend the effective domain of the function, albeit by
70  * introducing periodicity. -FKM 4/93
71  */
72 static void
73 filter_args(fastf_t *src, fastf_t *p, fastf_t *f, int *ip)
74 {
75  register int i;
76  point_t dst;
77  static unsigned long max2x = ~((unsigned long)0);
78  static unsigned long max = (~((unsigned long)0)) >> 1;
79 
80  for (i=0; i < 3; i++) {
81  /* assure values are positive */
82  dst[i] = fabs(src[i]);
83 
84  /* fold space */
85  while (dst[i] > max || dst[i]<0) {
86  if (dst[i] > max) {
87  dst[i] = max2x - dst[i];
88  } else {
89  dst[i] = -dst[i];
90  }
91  }
92 
93  }
94 
95  p[X] = dst[0];
96  ip[X] = floor(p[X]);
97  f[X] = p[X] - ip[X];
98 
99  p[Y] = dst[1];
100  ip[Y] = floor(p[Y]);
101  f[Y] = p[Y] - ip[Y];
102 
103  p[Z] = dst[2];
104  ip[Z] = floor(p[Z]);
105  f[Z] = p[Z] - ip[Z];
106 }
107 
108 
109 #define MAXSIZE 267 /* 255 + 3 * (4 values) */
110 
111 /**
112  * The RTable maps numbers into the range [-1..1]
113  */
114 static double RTable[MAXSIZE];
115 
116 #define INCRSUM(m, s, x, y, z) ((s)*(RTable[m]*0.5 \
117  + RTable[m+1]*(x) \
118  + RTable[m+2]*(y) \
119  + RTable[m+3]*(z)))
120 
121 
122 /**
123  * A heavily magic-number protected version of the hashtable.
124  *
125  * This table is used to convert integers into repeatable random
126  * results for indices into RTable.
127  */
128 struct str_ht {
129  uint32_t magic;
131  uint32_t *hashTableMagic1;
132  uint32_t *hashTable;
133  uint32_t *hashTableMagic2;
134  uint32_t magic_end;
135 };
136 
137 static struct str_ht ht;
138 
139 #define TABLE_SIZE 4096
140 
141 #define MAGIC_STRHT1 1771561
142 #define MAGIC_STRHT2 1651771
143 #define MAGIC_TAB1 9823
144 #define MAGIC_TAB2 784642
145 #define CK_HT() { \
146  BU_CKMAG(&ht.magic, MAGIC_STRHT1, "struct str_ht ht 1"); \
147  BU_CKMAG(&ht.magic_end, MAGIC_STRHT2, "struct str_ht ht 2"); \
148  BU_CKMAG(ht.hashTableMagic1, MAGIC_TAB1, "hashTable Magic 1"); \
149  BU_CKMAG(ht.hashTableMagic2, MAGIC_TAB2, "hashTable Magic 2"); \
150  if (ht.hashTable != &ht.hashTableMagic1[1]) \
151  bu_bomb("ht.hashTable changed rel ht.hashTableMagic1"); \
152  if (ht.hashTableMagic2 != &ht.hashTable[TABLE_SIZE]) \
153  bu_bomb("ht.hashTable changed rel ht.hashTableMagic2"); \
154  }
155 
156 
157 /**
158  * Map integer point into repeatable random number [0..TABLE_SIZE-1]
159  * (i.e., [0-4095]). We actually only use the first 8 bits of the
160  * final value extracted from this table. It's not quite clear that
161  * we really need this big a table. The extra size does provide some
162  * extra randomness for intermediate results.
163  */
164 #define Hash3d(a, b, c) \
165  ht.hashTable[ \
166  ht.hashTable[ \
167  ht.hashTable[(a) & 0xfff] ^ ((b) & 0xfff) \
168  ] ^ ((c) & 0xfff) \
169  ]
170 
171 
172 void
174 {
175  uint32_t i, j, k, temp;
176  uint32_t rndtabi = BN_RAND_TABSIZE - 1;
177 
179 
180  if (ht.hashTableValid) {
182  return;
183  }
184 
185  BN_RANDSEED(rndtabi, (BN_RAND_TABSIZE-1));
186 
187  /* alloc table size plus two magic numbers */
188  ht.hashTableMagic1 = (uint32_t *) bu_calloc(1, 2*sizeof(uint32_t) + TABLE_SIZE*sizeof(uint32_t), "noise hashTable");
189 
190  ht.hashTable = &ht.hashTableMagic1[1];
192 
193  *ht.hashTableMagic1 = (uint32_t)MAGIC_TAB1;
194  *ht.hashTableMagic2 = (uint32_t)MAGIC_TAB2;
195 
196  ht.magic_end = (uint32_t)MAGIC_STRHT2;
197  ht.magic = (uint32_t)MAGIC_STRHT1;
198 
199  for (i = 0; i < TABLE_SIZE; i++)
200  ht.hashTable[i] = i;
201 
202  /* scramble the hash table */
203  for (i = TABLE_SIZE-1; i > 0; i--) {
204  j = (uint32_t)(BN_RANDOM(rndtabi) * (fastf_t)TABLE_SIZE);
205 
206  temp = ht.hashTable[i];
207  ht.hashTable[i] = ht.hashTable[j];
208  ht.hashTable[j] = temp;
209  }
210 
211  BN_RANDSEED(k, 13);
212 
213  for (i = 0; i < MAXSIZE; i++)
214  RTable[i] = BN_RANDOM(k) * 2.0 - 1.0;
215 
216  ht.hashTableValid = 1;
217 
219 
220  CK_HT();
221 }
222 
223 
224 double
226 {
227  register int jx, jy, jz;
228  int ix, iy, iz; /* lower integer lattice point */
229  double x, y, z; /* corrected point */
230  double fx, fy, fz; /* distance above integer lattice point */
231  double sx, sy, sz, tx, ty, tz;
232  double sum;
233  short m;
234  point_t p, f;
235  int ip[3];
236 
237  if (!ht.hashTableValid)
238  bn_noise_init();
239 
240  /* IS: const fastf_t *, point_t, point_t, int[3] */
241  /* NE: fastf_t *, fastf_t *, fastf_t *, int * */
242  filter_args(point, p, f, ip);
243  ix = ip[X];
244  iy = ip[Y];
245  iz = ip[Z];
246 
247  fx = f[X];
248  fy = f[Y];
249  fz = f[Z];
250 
251  x = p[X];
252  y = p[Y];
253  z = p[Z];
254 
255  jx = ix + 1; /* (jx, jy, jz) = integer lattice point above (ix, iy, iz) */
256  jy = iy + 1;
257  jz = iz + 1;
258 
259  sx = SMOOTHSTEP(fx);
260  sy = SMOOTHSTEP(fy);
261  sz = SMOOTHSTEP(fz);
262 
263  /* the complement values of sx, sy, sz */
264  tx = 1.0 - sx;
265  ty = 1.0 - sy;
266  tz = 1.0 - sz;
267 
268  /*
269  * interpolate!
270  */
271  /* get a repeatable random # 0..TABLE_SIZE & 0xFF*/
272  m = Hash3d(ix, iy, iz) & 0xFF;
273  sum = INCRSUM(m, (tx*ty*tz), (x-ix), (y-iy), (z-iz));
274 
275  m = Hash3d(jx, iy, iz) & 0xFF;
276  sum += INCRSUM(m, (sx*ty*tz), (x-jx), (y-iy), (z-iz));
277 
278  m = Hash3d(ix, jy, iz) & 0xFF;
279  sum += INCRSUM(m, (tx*sy*tz), (x-ix), (y-jy), (z-iz));
280 
281  m = Hash3d(jx, jy, iz) & 0xFF;
282  sum += INCRSUM(m, (sx*sy*tz), (x-jx), (y-jy), (z-iz));
283 
284  m = Hash3d(ix, iy, jz) & 0xFF;
285  sum += INCRSUM(m, (tx*ty*sz), (x-ix), (y-iy), (z-jz));
286 
287  m = Hash3d(jx, iy, jz) & 0xFF;
288  sum += INCRSUM(m, (sx*ty*sz), (x-jx), (y-iy), (z-jz));
289 
290  m = Hash3d(ix, jy, jz) & 0xFF;
291  sum += INCRSUM(m, (tx*sy*sz), (x-ix), (y-jy), (z-jz));
292 
293  m = Hash3d(jx, jy, jz) & 0xFF;
294  sum += INCRSUM(m, (sx*sy*sz), (x-jx), (y-jy), (z-jz));
295 
296  return sum;
297 
298 }
299 
300 
301 void
303 {
304  register int jx, jy, jz;
305  int ix, iy, iz; /* lower integer lattice point */
306  double x, y, z; /* corrected point */
307  double px, py, pz, s;
308  double sx, sy, sz, tx, ty, tz;
309  short m;
310  point_t p, f;
311  int ip[3];
312 
313 
314  if (! ht.hashTableValid) bn_noise_init();
315 
316 
317  /* sets:
318  * x, y, z to range [0..maxval],
319  * ix, iy, iz to integer portion,
320  * fx, fy, fz to fractional portion
321  */
322  filter_args(point, p, f, ip);
323  ix = ip[X];
324  iy = ip[Y];
325  iz = ip[Z];
326 
327  x = p[X];
328  y = p[Y];
329  z = p[Z];
330 
331  jx = ix+1; jy = iy + 1; jz = iz + 1;
332 
333  sx = SMOOTHSTEP(x - ix);
334  sy = SMOOTHSTEP(y - iy);
335  sz = SMOOTHSTEP(z - iz);
336 
337  /* the complement values of sx, sy, sz */
338  tx = 1.0 - sx;
339  ty = 1.0 - sy;
340  tz = 1.0 - sz;
341 
342  /*
343  * interpolate!
344  */
345  m = Hash3d(ix, iy, iz) & 0xFF;
346  px = x-ix;
347  py = y-iy;
348  pz = z-iz;
349  s = tx*ty*tz;
350  result[0] = INCRSUM(m, s, px, py, pz);
351  result[1] = INCRSUM(m+4, s, px, py, pz);
352  result[2] = INCRSUM(m+8, s, px, py, pz);
353 
354  m = Hash3d(jx, iy, iz) & 0xFF;
355  px = x-jx;
356  s = sx*ty*tz;
357  result[0] += INCRSUM(m, s, px, py, pz);
358  result[1] += INCRSUM(m+4, s, px, py, pz);
359  result[2] += INCRSUM(m+8, s, px, py, pz);
360 
361  m = Hash3d(jx, jy, iz) & 0xFF;
362  py = y-jy;
363  s = sx*sy*tz;
364  result[0] += INCRSUM(m, s, px, py, pz);
365  result[1] += INCRSUM(m+4, s, px, py, pz);
366  result[2] += INCRSUM(m+8, s, px, py, pz);
367 
368  m = Hash3d(ix, jy, iz) & 0xFF;
369  px = x-ix;
370  s = tx*sy*tz;
371  result[0] += INCRSUM(m, s, px, py, pz);
372  result[1] += INCRSUM(m+4, s, px, py, pz);
373  result[2] += INCRSUM(m+8, s, px, py, pz);
374 
375  m = Hash3d(ix, jy, jz) & 0xFF;
376  pz = z-jz;
377  s = tx*sy*sz;
378  result[0] += INCRSUM(m, s, px, py, pz);
379  result[1] += INCRSUM(m+4, s, px, py, pz);
380  result[2] += INCRSUM(m+8, s, px, py, pz);
381 
382  m = Hash3d(jx, jy, jz) & 0xFF;
383  px = x-jx;
384  s = sx*sy*sz;
385  result[0] += INCRSUM(m, s, px, py, pz);
386  result[1] += INCRSUM(m+4, s, px, py, pz);
387  result[2] += INCRSUM(m+8, s, px, py, pz);
388 
389  m = Hash3d(jx, iy, jz) & 0xFF;
390  py = y-iy;
391  s = sx*ty*sz;
392  result[0] += INCRSUM(m, s, px, py, pz);
393  result[1] += INCRSUM(m+4, s, px, py, pz);
394  result[2] += INCRSUM(m+8, s, px, py, pz);
395 
396  m = Hash3d(ix, iy, jz) & 0xFF;
397  px = x-ix;
398  s = tx*ty*sz;
399  result[0] += INCRSUM(m, s, px, py, pz);
400  result[1] += INCRSUM(m+4, s, px, py, pz);
401  result[2] += INCRSUM(m+8, s, px, py, pz);
402 }
403 
404 
405 /**
406  * Spectral Noise functions
407  *
408  * The Spectral Noise functions cache the values of the term:
409  *
410  * (-h_val)
411  * freq
412  * Which on some systems is rather expensive to compute.
413  */
414 struct fbm_spec {
415  uint32_t magic;
416  double octaves;
417  double lacunarity;
418  double h_val;
419  double remainder;
420  double *spec_wgts;
421 };
422 #define MAGIC_fbm_spec_wgt 0x837592
423 
424 static struct fbm_spec *etbl = (struct fbm_spec *)NULL;
425 static int etbl_next = 0;
426 static int etbl_size = 0;
427 
428 #define PSCALE(_p, _s) _p[0] *= _s; _p[1] *= _s; _p[2] *= _s
429 #define PCOPY(_d, _s) _d[0] = _s[0]; _d[1] = _s[1]; _d[2] = _s[2]
430 
431 
432 static struct fbm_spec *
433 build_spec_tbl(double h_val, double lacunarity, double octaves)
434 {
435  struct fbm_spec *ep = NULL;
436  double frequency;
437  int i;
438 
439  /* The right spectral weights table for these parameters has not
440  * been pre-computed. As a result, we compute the table now and
441  * save it with the knowledge that we'll likely want it again
442  * later.
443  */
444 
445  /* allocate storage for new tables if needed */
446  if (etbl_next >= etbl_size) {
447  if (etbl_size) {
448  etbl_size *= 2;
449  etbl = (struct fbm_spec *)bu_realloc((void *)etbl,
450  etbl_size*sizeof(struct fbm_spec),
451  "spectral weights table");
452  } else {
453  etbl_size = 128;
454  etbl = (struct fbm_spec *)bu_calloc(etbl_size,
455  sizeof(struct fbm_spec),
456  "spectral weights table");
457  }
458  }
459 
460  /* set up the next available table */
461  ep = &etbl[etbl_next];
462  ep->h_val = h_val;
463  ep->lacunarity = lacunarity;
464  ep->octaves = octaves;
465  ep->spec_wgts = (double *)bu_calloc(((int)(octaves+1)), sizeof(double), "spectral weights");
467 
468  /* precompute and store spectral weights table */
469  for (frequency = 1.0, i=0; i < octaves; i++) {
470  /* compute weight for each frequency */
471  ep->spec_wgts[i] = pow(frequency, -h_val);
472  frequency *= lacunarity;
473  }
474 
475  etbl_next++; /* saved for last in case we're running multi-threaded */
476  return ep;
477 }
478 
479 
480 /**
481  * The first order of business is to see if we have pre-computed the
482  * spectral weights table for these parameters in a previous
483  * invocation. If not, then we compute them and save them for possible
484  * future use
485  */
486 struct fbm_spec *
487 find_spec_wgt(double h, double l, double o)
488 {
489  struct fbm_spec *ep = NULL;
490  int i;
491 
492  for (i=0; i < etbl_next; i++) {
493  ep = &etbl[i];
494  if (ep->magic != MAGIC_fbm_spec_wgt)
495  bu_bomb("find_spec_wgt");
496  if (EQUAL(ep->lacunarity, l)
497  && EQUAL(ep->h_val, h)
498  && (ep->octaves > o || EQUAL(ep->octaves, o)))
499  {
500  return ep;
501  }
502  }
503 
504  /* we didn't find the table we wanted so we've got to semaphore on
505  * the list to wait our turn to add what we want to the table.
506  */
507 
509 
510  /* We search the list one more time in case the last process to
511  * hold the semaphore just created the table we were about to add
512  */
513  for (i=0; i < etbl_next; i++) {
514  ep = &etbl[i];
515  if (ep->magic != MAGIC_fbm_spec_wgt)
516  bu_bomb("find_spec_wgt");
517  if (EQUAL(ep->lacunarity, l)
518  && EQUAL(ep->h_val, h)
519  && (ep->octaves > o || EQUAL(ep->octaves, o)))
520  {
521  break;
522  }
523  }
524 
525  if (i >= etbl_next)
526  ep = build_spec_tbl(h, l, o);
527 
529 
530  return ep;
531 }
532 
533 
534 double
536 {
537  struct fbm_spec *ep;
538  double value, noise_remainder, *spec_wgts;
539  point_t pt;
540  int i, oct;
541 
542  /* The first order of business is to see if we have pre-computed
543  * the spectral weights table for these parameters in a previous
544  * invocation. If not, then we compute them and save them for
545  * possible future use
546  */
547 
548  ep = find_spec_wgt(h_val, lacunarity, octaves);
549 
550  /* now we're ready to compute the fBm value */
551 
552  value = 0.0; /* initialize vars to proper values */
553  /* copy the point so we don't corrupt the caller's version */
554  PCOPY(pt, point);
555 
556  spec_wgts = ep->spec_wgts;
557 
558  /* inner loop of spectral construction */
559  oct=(int)octaves; /* save repeating double->int cast */
560  for (i=0; i < oct; i++) {
561  value += bn_noise_perlin(pt) * spec_wgts[i];
562  PSCALE(pt, lacunarity);
563  }
564 
565  noise_remainder = octaves - (int)octaves;
566  if (!ZERO(noise_remainder)) {
567  /* add in ``octaves'' noise_remainder ``i'' and spatial freq. are
568  * preset in loop above
569  */
570  value += noise_remainder * bn_noise_perlin(pt) * spec_wgts[i];
571  }
572 
573  return value;
574 
575 }
576 
577 
578 double
580 {
581  struct fbm_spec *ep;
582  double value, noise_remainder, *spec_wgts;
583  point_t pt;
584  int i, oct;
585 
586 
587  /* The first order of business is to see if we have pre-computed
588  * the spectral weights table for these parameters in a previous
589  * invocation. If not, then we compute them and save them for
590  * possible future use
591  */
592 
593  ep = find_spec_wgt(h_val, lacunarity, octaves);
594 
595  /* now we're ready to compute the fBm value */
596 
597  value = 0.0; /* initialize vars to proper values */
598  /* not cached: frequency = 1.0; */
599 
600  /* copy the point so we don't corrupt the caller's copy of the
601  * variable
602  */
603  PCOPY(pt, point);
604  spec_wgts = ep->spec_wgts;
605 
606  /* inner loop of spectral construction */
607  oct=(int)octaves; /* save repeating double->int cast */
608  for (i=0; i < oct; i++) {
609  /* not cached:
610  * value += fabs(bn_noise_perlin(pt)) * pow(frequency, -h_val);
611  * frequency *= lacunarity;
612  */
613  value += fabs(bn_noise_perlin(pt)) * spec_wgts[i];
614  PSCALE(pt, lacunarity);
615  }
616 
617  noise_remainder = octaves - (int)octaves;
618  if (!ZERO(noise_remainder)) {
619  /* add in ``octaves'' noise_remainder ``i'' and spatial freq. are
620  * preset in loop above
621  */
622  value += noise_remainder * bn_noise_perlin(pt) * spec_wgts[i];
623  /* not cached: value += noise_remainder * bn_noise_perlin(pt) * pow(frequency, -h_val); */
624  }
625 
626  return value;
627 
628 }
629 
630 
631 double
632 bn_noise_ridged(fastf_t *point, double h_val, double lacunarity, double octaves, double offset)
633 {
634  struct fbm_spec *ep;
635  double result, weight, noise_signal, *spec_wgts;
636  point_t pt;
637  int i;
638 
639  /* The first order of business is to see if we have pre-computed
640  * the spectral weights table for these parameters in a previous
641  * invocation. If not, then we compute them and save them for
642  * possible future use
643  */
644 
645  ep = find_spec_wgt(h_val, lacunarity, octaves);
646 
647  /* copy the point so we don't corrupt the caller's copy of the
648  * variable
649  */
650  PCOPY(pt, point);
651  spec_wgts = ep->spec_wgts;
652 
653 
654  /* get first octave */
655  noise_signal = bn_noise_perlin(pt);
656 
657  /* get absolute value of noise_signal (this creates the ridges) */
658  if (noise_signal < 0.0) noise_signal = -noise_signal;
659 
660  /* invert and translate (note that "offset should be ~= 1.0 */
661  noise_signal = offset - noise_signal;
662 
663  /* square the noise_signal, to increase "sharpness" of ridges */
664  noise_signal *= noise_signal;
665 
666  /* assign initial value */
667  result = noise_signal;
668  weight = 1.0;
669 
670  for (i=1; i < octaves; i++) {
671  PSCALE(pt, lacunarity);
672 
673  noise_signal = bn_noise_perlin(pt);
674 
675  if (noise_signal < 0.0) noise_signal = - noise_signal;
676  noise_signal = offset - noise_signal;
677 
678  /* weight the contribution */
679  noise_signal *= weight;
680  result += noise_signal * spec_wgts[i];
681  }
682  return result;
683 }
684 
685 
686 double
687 bn_noise_mf(fastf_t *point, double h_val, double lacunarity, double octaves, double offset)
688 {
689  double frequency = 1.0;
690  struct fbm_spec *ep;
691  double result, weight, noise_signal, *spec_wgts;
692  point_t pt;
693  int i;
694 
695  /* The first order of business is to see if we have pre-computed
696  * the spectral weights table for these parameters in a previous
697  * invocation. If not, then we compute them and save them for
698  * possible future use
699  */
700 
701  ep = find_spec_wgt(h_val, lacunarity, octaves);
702 
703  /* copy the point so we don't corrupt the caller's copy of the
704  * variable.
705  */
706  PCOPY(pt, point);
707  spec_wgts = ep->spec_wgts;
708  offset = 1.0;
709 
710  result = (bn_noise_perlin(pt) + offset) * spec_wgts[0];
711  weight = result;
712 
713  for (i=1; i < octaves; i++) {
714  PSCALE(pt, lacunarity);
715 
716  V_MIN(weight, 1.0);
717 
718  noise_signal = (bn_noise_perlin(pt) + offset) * spec_wgts[i];
719 
720  noise_signal += fabs(bn_noise_perlin(pt)) * pow(frequency, -h_val);
721  frequency *= lacunarity;
722  PSCALE(pt, lacunarity);
723  }
724  return result;
725 }
726 
727 /** @} */
728 /*
729  * Local Variables:
730  * mode: C
731  * tab-width: 8
732  * indent-tabs-mode: t
733  * c-file-style: "stroustrup"
734  * End:
735  * ex: shiftwidth=4 tabstop=8
736  */
uint32_t magic_end
Definition: noise.c:134
#define MAGIC_STRHT1
Definition: noise.c:141
if lu s
Definition: nmg_mod.c:3860
void bu_semaphore_acquire(unsigned int i)
Definition: semaphore.c:180
double remainder
Definition: noise.c:419
uint32_t magic
Definition: noise.c:415
#define BU_SEM_BN_NOISE
Definition: parallel.h:180
#define MAGIC_STRHT2
Definition: noise.c:142
uint32_t magic
Definition: noise.c:129
Header file for the BRL-CAD common definitions.
double * spec_wgts
Definition: noise.c:420
#define MAGIC_fbm_spec_wgt
Definition: noise.c:422
double octaves
Definition: noise.c:416
double lacunarity
Definition: noise.c:417
double bn_noise_ridged(fastf_t *point, double h_val, double lacunarity, double octaves, double offset)
Definition: noise.c:632
double h_val
Definition: noise.c:418
Definition: color.c:49
#define PCOPY(_d, _s)
Definition: noise.c:429
#define MAGIC_TAB1
Definition: noise.c:143
double bn_noise_turb(fastf_t *point, double h_val, double lacunarity, double octaves)
Definition: noise.c:579
void * bu_calloc(size_t nelem, size_t elsize, const char *str)
Definition: malloc.c:321
uint32_t * hashTableMagic1
Definition: noise.c:131
#define BN_RANDSEED(_i, _seed)
Definition: rand.h:60
Coord * point
Definition: chull3d.cpp:52
#define MAXSIZE
Definition: noise.c:109
void * bu_realloc(void *ptr, size_t siz, const char *str)
#define MAGIC_TAB2
Definition: noise.c:144
#define CK_HT()
Definition: noise.c:145
#define INCRSUM(m, s, x, y, z)
Definition: noise.c:116
void bu_semaphore_release(unsigned int i)
Definition: semaphore.c:218
double bn_noise_fbm(fastf_t *point, double h_val, double lacunarity, double octaves)
Definition: noise.c:535
#define ZERO(val)
Definition: units.c:38
uint32_t * hashTable
Definition: noise.c:132
#define Hash3d(a, b, c)
Definition: noise.c:164
struct fbm_spec * find_spec_wgt(double h, double l, double o)
Definition: noise.c:487
void bn_noise_init(void)
These noise functions provide mostly random noise at the integer lattice points. The functions should...
Definition: noise.c:173
char hashTableValid
Definition: noise.c:130
#define BN_RANDOM(_i)
Definition: rand.h:73
double bn_noise_mf(fastf_t *point, double h_val, double lacunarity, double octaves, double offset)
Definition: noise.c:687
#define BN_RAND_TABSIZE
A supply of fast pseudo-random numbers from table in bn/rand.c. The values are in the open interval (...
Definition: rand.h:58
Definition: color.c:51
#define TABLE_SIZE
Definition: noise.c:139
#define PSCALE(_p, _s)
Definition: noise.c:428
uint32_t * hashTableMagic2
Definition: noise.c:133
#define SMOOTHSTEP(x)
interpolate smoothly from 0 .. 1
Definition: noise.c:55
void bu_bomb(const char *str) _BU_ATTR_NORETURN
Definition: bomb.c:91
double fastf_t
Definition: defines.h:300
Definition: noise.c:128
double bn_noise_perlin(fastf_t *point)
Definition: noise.c:225
Definition: color.c:50
void bn_noise_vec(fastf_t *point, fastf_t *result)
Definition: noise.c:302