-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimplex_noise.h
73 lines (64 loc) · 2.56 KB
/
simplex_noise.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
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// Created by Afterwind on 10/12/2017.
//
#ifndef GAMEENGINE_SIMPLEX_NOISE_H
#define GAMEENGINE_SIMPLEX_NOISE_H
/* sdnoise1234, Simplex noise with true analytic
* derivative in 1D to 4D.
*
* 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 C header file for Perlin simplex noise with analytic
derivative over 1, 2, 3 and 4 dimensions.
\author Stefan Gustavson ([email protected])
*/
/*
* This is an implementation of Perlin "simplex noise" over one
* dimension (x), two dimensions (x,y), three dimensions (x,y,z)
* and four dimensions (x,y,z,w). The analytic derivative is
* returned, to make it possible to do lots of fun stuff like
* flow animations, curl noise, analytic antialiasing and such.
*
* Visually, this noise is exactly the same as the plain version of
* simplex noise provided in the file "snoise1234.c". It just returns
* all partial derivatives in addition to the scalar noise value.
*
*/
#include <math.h>
/** 1D simplex noise with derivative.
* If the last argument is not null, the analytic derivative
* is also calculated.
*/
float sdnoise1( float x, float *dnoise_dx);
/** 2D simplex noise with derivatives.
* If the last two arguments are not null, the analytic derivative
* (the 2D gradient of the scalar noise field) is also calculated.
*/
float sdnoise2( float x, float y, float *dnoise_dx, float *dnoise_dy );
/** 3D simplex noise with derivatives.
* If the last tthree arguments are not null, the analytic derivative
* (the 3D gradient of the scalar noise field) is also calculated.
*/
float sdnoise3( float x, float y, float z,
float *dnoise_dx, float *dnoise_dy, float *dnoise_dz );
/** 4D simplex noise with derivatives.
* If the last four arguments are not null, the analytic derivative
* (the 4D gradient of the scalar noise field) is also calculated.
*/
float sdnoise4( float x, float y, float z, float w,
float *dnoise_dx, float *dnoise_dy,
float *dnoise_dz, float *dnoise_dw);
#endif //GAMEENGINE_SIMPLEX_NOISE_H