HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_NoiseBasis.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_NoiseBasis.h ( UT Library, C++)
7  *
8  * COMMENTS: Low level noise generation using cellular basis functions
9  * This is based off: "A Cellular Texture Basis Function",
10  * Siggraph 1996, pg. 291. It can provide noise similar to
11  * alligator noise (which was developed independently).
12  *
13  * NOTES: This noise type can be considered a super-set of alligator and
14  * sparse convolution noise. Alligator noise is created using a
15  * simple linear combination of (1-F(0)) - (1-F(3)) or something
16  * to that effect. Sparse convolution on the other hand can be
17  * generated by:
18  * sum(.5*cos(F(i)*FACTOR)+.5)
19  */
20 
21 #ifndef __UT_NoiseBasis__
22 #define __UT_NoiseBasis__
23 
24 #include "UT_API.h"
25 #include <SYS/SYS_Types.h>
26 
28 public:
29  union {
30  float myDistance;
31  int myIDistance; // Used internally
32  };
34 };
35 
37 {
38  Euclidean,
39  Manhattan,
40  Chebyshev
41 };
42 
43 template <UT_NoiseBasisMetric METRIC=UT_NoiseBasisMetric::Euclidean>
45 {
46 public:
47  static void initNoise();
48 
49  // Voronoi noise (Euclidean distance metric)
50  static void noise1D(float pos, UT_NoiseValue vals[], int nvals);
51  static void noise2D(const fpreal32 pos[2], UT_NoiseValue vals[], int nvals);
52  static void noise2D(const fpreal64 pos[2], UT_NoiseValue vals[], int nvals);
53  static void noise3D(const fpreal32 pos[3], UT_NoiseValue vals[], int nvals);
54  static void noise3D(const fpreal64 pos[3], UT_NoiseValue vals[], int nvals);
55  static void noise4D(const fpreal32 pos[4], UT_NoiseValue vals[], int nvals);
56  static void noise4D(const fpreal64 pos[4], UT_NoiseValue vals[], int nvals);
57  static void noise1D(float pos, UT_NoiseValue vals[], int nvals, uint period);
58  static void noise2D(const fpreal32 pos[2], UT_NoiseValue vals[], int nvals,
59  uint periodx, uint periody);
60  static void noise2D(const fpreal64 pos[2], UT_NoiseValue vals[], int nvals,
61  uint periodx, uint periody);
62  static void noise3D(const fpreal32 pos[3], UT_NoiseValue vals[], int nvals,
63  uint periodx, uint periody, uint periodz);
64  static void noise3D(const fpreal64 pos[3], UT_NoiseValue vals[], int nvals,
65  uint periodx, uint periody, uint periodz);
66  static void noise4D(const fpreal32 pos[4], UT_NoiseValue vals[], int nvals,
67  uint periodx, uint periody, uint periodz, uint periodw);
68  static void noise4D(const fpreal64 pos[4], UT_NoiseValue vals[], int nvals,
69  uint periodx, uint periody, uint periodz, uint periodw);
70 
71  // For periodic noise, the period should contain dimension values (one for
72  // each dimension)
73  template <typename T>
74  static inline void noise2D(const T pos[2], UT_NoiseValue vals[],
75  int nvals, const uint period[2])
76  { noise2D(pos, vals, nvals, period[0], period[1]); }
77  template <typename T>
78  static inline void noise3D(const T pos[3], UT_NoiseValue vals[],
79  int nvals, const uint period[3])
80  {
81  noise3D(pos, vals, nvals, period[0], period[1],
82  period[2]);
83  }
84  template <typename T>
85  static inline void noise4D(const T pos[4], UT_NoiseValue vals[],
86  int nvals, const uint period[4])
87  {
88  noise4D(pos, vals, nvals, period[0], period[1],
89  period[2], period[3]);
90  }
91 
92  // Voronoi noise with jitter (Euclidean distance metric)
93  static void noise1D(const fpreal32 P[1],
94  const fpreal32 *jitter, int32 *period,
95  int32 &seed, fpreal32 &f1, fpreal32 &f2,
96  fpreal32 p0[1], fpreal32 p1[1]);
97  static void noise2D(const fpreal32 P[2],
98  const fpreal32 *jitter, int32 *period,
99  int32 &seed, fpreal32 &f1, fpreal32 &f2,
100  fpreal32 p0[2], fpreal32 p1[2]);
101  static void noise3D(const fpreal32 P[3],
102  const fpreal32 *jitter, int32 *period,
103  int32 &seed, fpreal32 &f1, fpreal32 &f2,
104  fpreal32 p0[3], fpreal32 p1[3]);
105  static void noise4D(const fpreal32 P[4],
106  const fpreal32 *jitter, int32 *period,
107  int32 &seed, fpreal32 &f1, fpreal32 &f2,
108  fpreal32 p0[4], fpreal32 p1[4]);
109 
110  static void noise1D(const fpreal64 P[1],
111  const fpreal64 *jitter, int64 *period,
112  int64 &seed, fpreal64 &f1, fpreal64 &f2,
113  fpreal64 p0[1], fpreal64 p1[1]);
114  static void noise2D(const fpreal64 P[2],
115  const fpreal64 *jitter, int64 *period,
116  int64 &seed, fpreal64 &f1, fpreal64 &f2,
117  fpreal64 p0[2], fpreal64 p1[2]);
118  static void noise3D(const fpreal64 P[3],
119  const fpreal64 *jitter, int64 *period,
120  int64 &seed, fpreal64 &f1, fpreal64 &f2,
121  fpreal64 p0[3], fpreal64 p1[3]);
122  static void noise4D(const fpreal64 P[4],
123  const fpreal64 *jitter, int64 *period,
124  int64 &seed, fpreal64 &f1, fpreal64 &f2,
125  fpreal64 p0[4], fpreal64 p1[4]);
126 private:
127 };
128 
129 #endif
int int32
Definition: SYS_Types.h:39
UT_NoiseBasisMetric
Definition: UT_NoiseBasis.h:36
#define UT_API
Definition: UT_API.h:14
static void noise2D(const T pos[2], UT_NoiseValue vals[], int nvals, const uint period[2])
Definition: UT_NoiseBasis.h:74
float fpreal32
Definition: SYS_Types.h:200
static void noise3D(const T pos[3], UT_NoiseValue vals[], int nvals, const uint period[3])
Definition: UT_NoiseBasis.h:78
double fpreal64
Definition: SYS_Types.h:201
long long int64
Definition: SYS_Types.h:116
unsigned int uint
Definition: SYS_Types.h:45
static void noise4D(const T pos[4], UT_NoiseValue vals[], int nvals, const uint period[4])
Definition: UT_NoiseBasis.h:85