-
Notifications
You must be signed in to change notification settings - Fork 6
/
simplexnoise1234.h
60 lines (52 loc) · 1.99 KB
/
simplexnoise1234.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// SimplexNoise1234
// Copyright ?2003-2011, Stefan Gustavson
//
// Contact: [email protected]
//
// This library is public domain software, released by the author
// into the public domain in February 2011. You may do anything
// you like with it. You may even remove all attributions,
// but of course I'd appreciate it if you kept my name somewhere.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
/** \file
\brief Declares the SimplexNoise1234 class for producing Perlin simplex noise.
\author Stefan Gustavson ([email protected])
*/
/*
* This is a clean, fast, modern and free Perlin Simplex noise class in C++.
* Being a stand-alone class with no external dependencies, it is
* highly reusable without source code modifications.
*
*
* Note:
* Replacing the "float" type with "double" can actually make this run faster
* on some platforms. A templatized version of SimplexNoise1234 could be useful.
*/
class SimplexNoise1234 {
public:
SimplexNoise1234() {}
~SimplexNoise1234() {}
/** 1D, 2D, 3D and 4D float Perlin noise
*/
static float noise( float x );
static float noise( float x, float y );
static float noise( float x, float y, float z );
static float noise( float x, float y, float z, float w );
/** 1D, 2D, 3D and 4D float Perlin noise, with a specified integer period
*/
static float pnoise( float x, int px );
static float pnoise( float x, float y, int px, int py );
static float pnoise( float x, float y, float z, int px, int py, int pz );
static float pnoise( float x, float y, float z, float w,
int px, int py, int pz, int pw );
private:
static unsigned char perm[];
static float grad( int hash, float x );
static float grad( int hash, float x, float y );
static float grad( int hash, float x, float y , float z );
static float grad( int hash, float x, float y, float z, float t );
};