HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_XNoise.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_XNoise.h ( UT Library, C++)
7  *
8  * COMMENTS: Simplex noise and curlnoise based on its derivatives
9  *
10  */
11 
12 #ifndef __UT_XNoise__
13 #define __UT_XNoise__
14 
15 #include "UT_API.h"
16 #include <SYS/SYS_Types.h>
17 
19 public:
20  static void initNoise();
21 
22  // The internal permutation and random tables and size. We can pass this
23  // buffer to OpenCL functions in $SHS/ocl/include/xnoise.h.
24  static void *data();
25  static size_t dataSize();
26 
27  // Scalar noise functions
28  template <typename T>
29  static inline float noise2D(const T x[2])
30  { return UT_XNoise::noise2D(x[0], x[1]); }
31  static float noise1D(float x);
32  static float noise2D(float x, float y);
33  static float noise3D(const fpreal32 x[3]);
34  static float noise3D(const fpreal64 x[3]);
35  static float noise4D(const fpreal32 x[4]);
36  static float noise4D(const fpreal64 x[4]);
37 
38  // Scalar noise functions with derivatives
39  template <typename T>
40  static inline void noise2D(T &n, T &dndx, T &dndy, const T x[2])
41  { UT_XNoise::noise2D(n, dndx, dndy, x[0], x[1]); }
42  static void noise1D(fpreal32 &n, fpreal32 &dndx, fpreal32 x);
43  static void noise2D(fpreal32 &n, fpreal32 &dndx, fpreal32 &dndy,
44  fpreal32 x, fpreal32 y);
45  static void noise3D(fpreal32 &n,
46  fpreal32 &dndx, fpreal32 &dndy, fpreal32 &dndz,
47  const fpreal32 x[3]);
48  static void noise4D(fpreal32 &n,
49  fpreal32 &dndx, fpreal32 &dndy,
50  fpreal32 &dndz, fpreal32 &dndw,
51  const fpreal32 x[4]);
52  static void noise1D(fpreal64 &n, fpreal64 &dndx, fpreal64 x);
53  static void noise2D(fpreal64 &n, fpreal64 &dndx, fpreal64 &dndy,
54  fpreal64 x, fpreal64 y);
55  static void noise3D(fpreal64 &n,
56  fpreal64 &dndx, fpreal64 &dndy, fpreal64 &dndz,
57  const fpreal64 x[3]);
58  static void noise4D(fpreal64 &n,
59  fpreal64 &dndx, fpreal64 &dndy,
60  fpreal64 &dndz, fpreal64 &dndw,
61  const fpreal64 x[4]);
62 
63  // Vector noise functions
64  template <typename T>
65  static inline void noise2D(T n[3], const T x[2])
66  { UT_XNoise::noise2D(n, x[0], x[1]); }
67  static void noise1D(fpreal32 n[3], fpreal32 x);
68  static void noise2D(fpreal32 n[3], fpreal32 x, fpreal32 y);
69  static void noise3D(fpreal32 n[3], const fpreal32 x[3]);
70  static void noise4D(fpreal32 n[3], const fpreal32 x[4]);
71  static void noise1D(fpreal64 n[3], fpreal64 x);
72  static void noise2D(fpreal64 n[3], fpreal64 x, fpreal64 y);
73  static void noise3D(fpreal64 n[3], const fpreal64 x[3]);
74  static void noise4D(fpreal64 n[3], const fpreal64 x[4]);
75 
76  // Vector noise functions with derivatives
77  template <typename T>
78  static inline void noise2D(float n[3], float dndx[3], float dndy[3],
79  const float x[2])
80  { UT_XNoise::noise2D(n, dndx, dndy, x[0], x[1]); }
81  static void noise1D(fpreal32 n[3], fpreal32 dndx[3], fpreal32 x);
82  static void noise2D(fpreal32 n[3], fpreal32 dndx[3],
83  fpreal32 dndy[3], fpreal32 x, fpreal32 y);
84  static void noise3D(fpreal32 n[3], fpreal32 dndx[3],
85  fpreal32 dndy[3], fpreal32 dndz[3],
86  const fpreal32 x[3]);
87  static void noise4D(fpreal32 n[3], fpreal32 dndx[3],
88  fpreal32 dndy[3], fpreal32 dndz[3],
89  fpreal32 dndw[3], const fpreal32 x[4]);
90  static void noise1D(fpreal64 n[3], fpreal64 dndx[3], fpreal64 x);
91  static void noise2D(fpreal64 n[3], fpreal64 dndx[3],
92  fpreal64 dndy[3], fpreal64 x, fpreal64 y);
93  static void noise3D(fpreal64 n[3], fpreal64 dndx[3],
94  fpreal64 dndy[3], fpreal64 dndz[3],
95  const fpreal64 x[3]);
96  static void noise4D(fpreal64 n[3], fpreal64 dndx[3],
97  fpreal64 dndy[3], fpreal64 dndz[3],
98  fpreal64 dndw[3], const fpreal64 x[4]);
99 
100  // Curlnoise functions
101  // 2D curlnoise from scalar noise
102  static void curlnoise2D2D(fpreal32 n[3], fpreal32 x, fpreal32 y);
103  static void curlnoise2D2D(fpreal64 n[3], fpreal64 x, fpreal64 y);
104  static void curlnoise2D3D(fpreal32 n[3], const fpreal32 x[3]);
105  static void curlnoise2D3D(fpreal64 n[3], const fpreal64 x[3]);
106  // 3D curlnoise from vector noise
107  static void curlnoise3D3D(fpreal32 n[3], const fpreal32 x[3]);
108  static void curlnoise3D3D(fpreal64 n[3], const fpreal64 x[3]);
109  static void curlnoise3D4D(fpreal32 n[3], const fpreal32 x[4]);
110  static void curlnoise3D4D(fpreal64 n[3], const fpreal64 x[4]);
111 };
112 
113 #endif
static float noise2D(const T x[2])
Definition: UT_XNoise.h:29
#define UT_API
Definition: UT_API.h:12
GLint y
Definition: glcorearb.h:102
static void noise2D(float n[3], float dndx[3], float dndy[3], const float x[2])
Definition: UT_XNoise.h:78
static void noise2D(T &n, T &dndx, T &dndy, const T x[2])
Definition: UT_XNoise.h:40
GLdouble n
Definition: glcorearb.h:2007
double fpreal64
Definition: SYS_Types.h:185
GLboolean * data
Definition: glcorearb.h:130
static void noise2D(T n[3], const T x[2])
Definition: UT_XNoise.h:65
GLint GLenum GLint x
Definition: glcorearb.h:408
float fpreal32
Definition: SYS_Types.h:184