HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_PNoise.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_PNoise.h ( UT Library, C++)
7  *
8  * COMMENTS: New, nicely bounded noise functions.
9  * Allows for periodicity of noise as well.
10  */
11 
12 #ifndef __UT_PNoise__
13 #define __UT_PNoise__
14 
15 #include "UT_API.h"
16 #include <SYS/SYS_Types.h>
17 
18 #include "UT_VectorTypes.h"
19 
21 public:
22  static void initNoise();
23 
24  // Non-periodic noise functions
25  static float noise1D(float x);
26  template <typename T>
27  static inline float noise2D(const T x[2])
28  { return noise2D(x[0], x[1]); }
29  static float noise2D(float x, float y);
30  static float noise3D(const fpreal32 x[3]);
31  static float noise3D(const fpreal64 x[3]);
32  static float noise4D(const fpreal32 x[4]);
33  static float noise4D(const fpreal64 x[4]);
34 
35  // Non-periodic noise functions with derivatives
36  template <typename T>
37  static inline void noise2D(T &n, T &dndx, T &dndy, const T x[2])
38  { noise2D(n, dndx, dndy, x[0], x[1]); }
39  static void noise1D(fpreal32 &n, fpreal32 &dndx, fpreal32 x);
40  static void noise2D(fpreal32 &n, fpreal32 &dndx,
41  fpreal32 &dndy, fpreal32 x, fpreal32 y);
42  static void noise3D(fpreal32 &n, fpreal32 &dndx,
43  fpreal32 &dndy, fpreal32 &dndz,
44  const fpreal32 x[3]);
45  static void noise4D(fpreal32 &n, fpreal32 &dndx,
46  fpreal32 &dndy, fpreal32 &dndz,
47  fpreal32 &dndw, const fpreal32 x[4]);
48  static void noise1D(fpreal64 &n, fpreal64 &dndx, fpreal64 x);
49  static void noise2D(fpreal64 &n, fpreal64 &dndx,
50  fpreal64 &dndy, fpreal64 x, fpreal64 y);
51  static void noise3D(fpreal64 &n, fpreal64 &dndx,
52  fpreal64 &dndy, fpreal64 &dndz,
53  const fpreal64 x[3]);
54  static void noise4D(fpreal64 &n, fpreal64 &dndx,
55  fpreal64 &dndy, fpreal64 &dndz,
56  fpreal64 &dndw, const fpreal64 x[4]);
57 
58  // Flow values are 0..1 and are periodic.
59  static float flownoise2D(float x, float y, float flow);
60  template <typename T>
61  static inline float flownoise2D(const T x[2], float flow)
62  { return flownoise2D(x[0], x[1], flow); }
63  static float flownoise3D(const fpreal32 x[3], float flow);
64  static float flownoise3D(const fpreal64 x[3], float flow);
65  static float flownoise4D(const fpreal32 x[4], float flow);
66  static float flownoise4D(const fpreal64 x[4], float flow);
67 
68  // Vectorized scalar noise
69  static void noise1D(fpreal32 *dest, const fpreal32 *src, int n);
70  static void noise2D(fpreal32 *dest,
71  const fpreal32 *x, const fpreal32 *y, int n);
72  static void noise3D(fpreal32 *dest, const UT_Vector3F *src, int n);
73  static void noise4D(fpreal32 *dest, const UT_Vector4F *src, int n);
74 
75  // Periodic noise functions. The period specified should be != 0
76  static float noise1D(float x, uint period);
77  template <typename T>
78  static inline float noise2D(const T x[2], const uint per[2])
79  { return noise2D(x[0], x[1], per[0], per[1]); }
80  static float noise2D(float x, float y, uint px, uint py);
81  static float noise3D(const fpreal32 x[3], const uint period[3]);
82  static float noise3D(const fpreal64 x[3], const uint period[3]);
83  static float noise4D(const fpreal32 x[4], const uint period[4]);
84  static float noise4D(const fpreal64 x[4], const uint period[4]);
85 
86  // Flow versions of periodic noise (note flow variable always periodic)
87  template <typename T>
88  static inline float flownoise2D(const float x[2],
89  const uint period[2], float flow)
90  {
91  return flownoise2D(x[0], x[1], period[0], period[1], flow);
92  }
93  static float flownoise2D(float x, float y,
94  uint px, uint py, float flow);
95  static float flownoise3D(const fpreal32 x[3],
96  const uint period[3], float flow);
97  static float flownoise3D(const fpreal64 x[3],
98  const uint period[3], float flow);
99  static float flownoise4D(const fpreal32 x[4],
100  const uint period[4], float flow);
101  static float flownoise4D(const fpreal64 x[4],
102  const uint period[4], float flow);
103 
104  // Non-periodic vector noise functions
105  static void noise1D(fpreal32 n[3], float x);
106  static void noise1D(fpreal64 n[3], float x);
107  template <typename T>
108  static inline void noise2D(T n[3], const T x[2])
109  { noise2D(n, x[0], x[1]); }
110  static void noise2D(fpreal32 n[3], float x, float y);
111  static void noise2D(fpreal64 n[3], float x, float y);
112  static void noise3D(fpreal32 n[3], const fpreal32 x[3]);
113  static void noise3D(fpreal64 n[3], const fpreal64 x[3]);
114  static void noise4D(fpreal32 n[3], const fpreal32 x[4]);
115  static void noise4D(fpreal64 n[3], const fpreal64 x[4]);
116 
117  // Non-periodic vector noise functions with derivatives
118  template <typename T>
119  static inline void noise2D(T n[3], T dndx[3], T dndy[3], const T x[2])
120  { noise2D(n, dndx, dndy, x[0], x[1]); }
121  static void noise1D(fpreal32 n[3], fpreal32 dndx[3], fpreal32 x);
122  static void noise2D(fpreal32 n[3], fpreal32 dndx[3],
123  fpreal32 dndy[3], fpreal32 x, fpreal32 y);
124  static void noise3D(fpreal32 n[3], fpreal32 dndx[3],
125  fpreal32 dndy[3], fpreal32 dndz[3],
126  const fpreal32 x[3]);
127  static void noise4D(fpreal32 n[3], fpreal32 dndx[3],
128  fpreal32 dndy[3], fpreal32 dndz[3],
129  fpreal32 dndw[3], const fpreal32 x[4]);
130  static void noise1D(fpreal64 n[3], fpreal64 dndx[3], fpreal64 x);
131  static void noise2D(fpreal64 n[3], fpreal64 dndx[3],
132  fpreal64 dndy[3], fpreal64 x, fpreal64 y);
133  static void noise3D(fpreal64 n[3], fpreal64 dndx[3],
134  fpreal64 dndy[3], fpreal64 dndz[3],
135  const fpreal64 x[3]);
136  static void noise4D(fpreal64 n[3], fpreal64 dndx[3],
137  fpreal64 dndy[3], fpreal64 dndz[3],
138  fpreal64 dndw[3], const fpreal64 x[4]);
139 
140  // Flow vector noise, non-periodic
141  template <typename T>
142  static inline void flownoise2D(T n[3],
143  const T x[2], float flow)
144  { flownoise2D(n, x[0], x[1], flow); }
145  static void flownoise2D(fpreal32 n[3],
146  float x, float y, float flow);
147  static void flownoise3D(fpreal32 n[3],
148  const fpreal32 x[3], float flow);
149  static void flownoise4D(fpreal32 n[3],
150  const fpreal32 x[4], float flow);
151 
152  template <typename T>
153  static inline void flownoise2D(fpreal64 n[3],
154  const fpreal64 x[2], float flow)
155  { flownoise2D(n, x[0], x[1], flow); }
156  static void flownoise2D(fpreal64 n[3],
157  float x, float y, float flow);
158  static void flownoise3D(fpreal64 n[3],
159  const fpreal64 x[3], float flow);
160  static void flownoise4D(fpreal64 n[3],
161  const fpreal64 x[4], float flow);
162 
163  // Vectorized vector noise
164  static void noise1D(UT_Vector3 *dest, const fpreal32 *P, int n);
165  static void noise2D(UT_Vector3 *dest,
166  const fpreal32 *x, const fpreal32 *y, int n);
167  static void noise3D(UT_Vector3 *dest, const UT_Vector3 *P, int n);
168  static void noise4D(UT_Vector3 *dest, const UT_Vector4 *P, int n);
169 
170  // Periodic vector noise functions
171  static void noise1D(fpreal32 n[3], float x, uint per);
172  static void noise1D(fpreal64 n[3], float x, uint per);
173  template <typename T>
174  static inline void noise2D(float n[3], const float x[2], const uint per[2])
175  { noise2D(n, x[0], x[1], per[0], per[1]); }
176  static void noise2D(fpreal32 n[3], float x, float y,
177  uint px, uint py);
178  static void noise2D(fpreal64 n[3], float x, float y,
179  uint px, uint py);
180  static void noise3D(fpreal32 n[3],
181  const fpreal32 x[3], const uint per[3]);
182  static void noise3D(fpreal64 n[3],
183  const fpreal64 x[3], const uint per[3]);
184  static void noise4D(fpreal32 n[3],
185  const fpreal32 x[4], const uint per[4]);
186  static void noise4D(fpreal64 n[3],
187  const fpreal64 x[4], const uint per[4]);
188 
189  // Periodic vector noise, flow
190  template <typename T>
191  static inline void flownoise2D(T n[3], const T x[2],
192  const uint per[2], float flow)
193  {
194  flownoise2D(n, x[0], x[1], per[0], per[1], flow);
195  }
196  static void flownoise2D(fpreal32 n[3], float x, float y,
197  uint px, uint py, float flow);
198  static void flownoise2D(fpreal64 n[3], float x, float y,
199  uint px, uint py, float flow);
200  static void flownoise3D(fpreal32 n[3], const fpreal32 x[3],
201  const uint per[3], float flow);
202  static void flownoise3D(fpreal64 n[3], const fpreal64 x[3],
203  const uint per[3], float flow);
204  static void flownoise4D(fpreal32 n[3], const fpreal32 x[4],
205  const uint per[4], float flow);
206  static void flownoise4D(fpreal64 n[3], const fpreal64 x[4],
207  const uint per[4], float flow);
208 
209  // Curlnoise functions
210  static void curlnoise2D2D(fpreal32 n[3], fpreal32 x, fpreal32 y);
211  static void curlnoise2D3D(fpreal32 n[3], const fpreal32 x[3]);
212  static void curlnoise3D3D(fpreal32 n[3], const fpreal32 x[3]);
213  static void curlnoise3D4D(fpreal32 n[3], const fpreal32 x[4]);
214 
215  static void curlnoise2D2D(fpreal64 n[3], fpreal64 x, fpreal64 y);
216  static void curlnoise2D3D(fpreal64 n[3], const fpreal64 x[3]);
217  static void curlnoise3D3D(fpreal64 n[3], const fpreal64 x[3]);
218  static void curlnoise3D4D(fpreal64 n[3], const fpreal64 x[4]);
219 };
220 
221 #endif
222 
static void noise2D(float n[3], const float x[2], const uint per[2])
Definition: UT_PNoise.h:174
static void flownoise2D(T n[3], const T x[2], const uint per[2], float flow)
Definition: UT_PNoise.h:191
static float flownoise2D(const T x[2], float flow)
Definition: UT_PNoise.h:61
static float flownoise2D(const float x[2], const uint period[2], float flow)
Definition: UT_PNoise.h:88
#define UT_API
Definition: UT_API.h:12
static void noise2D(T n[3], T dndx[3], T dndy[3], const T x[2])
Definition: UT_PNoise.h:119
GLint y
Definition: glcorearb.h:102
GLdouble n
Definition: glcorearb.h:2007
double fpreal64
Definition: SYS_Types.h:191
static void flownoise2D(fpreal64 n[3], const fpreal64 x[2], float flow)
Definition: UT_PNoise.h:153
unsigned int uint
Definition: SYS_Types.h:39
IFDmantra py
Definition: HDK_Image.dox:266
GLint GLenum GLint x
Definition: glcorearb.h:408
static void noise2D(T n[3], const T x[2])
Definition: UT_PNoise.h:108
static float noise2D(const T x[2])
Definition: UT_PNoise.h:27
float fpreal32
Definition: SYS_Types.h:190
static void noise2D(T &n, T &dndx, T &dndy, const T x[2])
Definition: UT_PNoise.h:37
static float noise2D(const T x[2], const uint per[2])
Definition: UT_PNoise.h:78
static void flownoise2D(T n[3], const T x[2], float flow)
Definition: UT_PNoise.h:142
GLenum src
Definition: glcorearb.h:1792