picrate 2.4.0-java → 2.4.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +1 -1
- data/lib/picrate/native_folder.rb +1 -1
- data/lib/picrate/version.rb +1 -1
- data/pom.rb +2 -2
- data/pom.xml +2 -2
- data/src/main/java/monkstone/FastNoiseModuleJava.java +19 -19
- data/src/main/java/monkstone/SmoothNoiseModuleJava.java +19 -19
- data/src/main/java/monkstone/noise/OpenSimplex2F.java +838 -737
- data/src/main/java/monkstone/noise/OpenSimplex2S.java +1 -1
- data/vendors/Rakefile +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cecab16a0e1abbcc010dc18037cba16121861f942a95aff9a898f9a5af4582ef
|
4
|
+
data.tar.gz: 3990c04c7008c66b54cf1af01d81980b7037ede67f6579bebb1294dd503a0260
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e365629d95d9077838b5a65300144fb817022dbfb21eda3754903f41aa29d39345986bc90d24021b9b1776f4f6b28206cab68ebda35f199502dcfe8a8ea1d8c0
|
7
|
+
data.tar.gz: 214a0c654b63653da787cf5afbd762420e3d6ae5d2e8ac9563b3b927ead5b7f3d10d7b63061cc1dea364511d3f39527296e2653e54dcd177cb87813666332210
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
v2.4.1 patch library loader, add PGS library examples.
|
2
|
+
|
1
3
|
v2.4.0 Refactor noise to two modules, FastNoise (default) & SmoothNoise, with terrain noise `:tnoise` option.
|
2
4
|
|
3
5
|
v2.3.0 Abandon Processing Value Noise in favour of OpenSimplex2, with choosable options. Added pdf library using iText5.
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ Requires java to build (and [jogl-2.4.0-rc jars][jogl_jars]), but uses a maven w
|
|
19
19
|
```bash
|
20
20
|
cd PiCrate # or whatever you call it
|
21
21
|
rake # assumes an installed version of vanilla processing
|
22
|
-
jgem install picrate-2.4.
|
22
|
+
jgem install picrate-2.4.1-java.gem
|
23
23
|
|
24
24
|
```
|
25
25
|
To create a template sketch:-
|
data/lib/picrate/version.rb
CHANGED
data/pom.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
project 'picrate', 'http://maven.apache.org' do
|
4
4
|
model_version '4.0.0'
|
5
|
-
id 'ruby-processing:picrate:2.4.
|
5
|
+
id 'ruby-processing:picrate:2.4.1'
|
6
6
|
packaging 'jar'
|
7
7
|
|
8
8
|
description 'An integrated processing-core (somewhat hacked), with additional java code for a jruby version of processing.'
|
@@ -33,7 +33,7 @@ project 'picrate', 'http://maven.apache.org' do
|
|
33
33
|
'project.build.sourceEncoding' => 'UTF-8',
|
34
34
|
'polyglot.dump.pom' => 'pom.xml')
|
35
35
|
|
36
|
-
pom 'org.jruby:jruby:9.2.
|
36
|
+
pom 'org.jruby:jruby:9.2.17.0'
|
37
37
|
jar 'org.jogamp.jogl:jogl-all:${jogl.version}'
|
38
38
|
jar 'org.jogamp.gluegen:gluegen-rt-main:${jogl.version}'
|
39
39
|
jar 'org.processing:video:3.0.2'
|
data/pom.xml
CHANGED
@@ -11,7 +11,7 @@ DO NOT MODIFY - GENERATED CODE
|
|
11
11
|
<modelVersion>4.0.0</modelVersion>
|
12
12
|
<groupId>ruby-processing</groupId>
|
13
13
|
<artifactId>picrate</artifactId>
|
14
|
-
<version>2.4.
|
14
|
+
<version>2.4.1</version>
|
15
15
|
<name>picrate</name>
|
16
16
|
<description>An integrated processing-core (somewhat hacked), with additional java code for a jruby version of processing.</description>
|
17
17
|
<url>http://maven.apache.org</url>
|
@@ -78,7 +78,7 @@ DO NOT MODIFY - GENERATED CODE
|
|
78
78
|
<dependency>
|
79
79
|
<groupId>org.jruby</groupId>
|
80
80
|
<artifactId>jruby</artifactId>
|
81
|
-
<version>9.2.
|
81
|
+
<version>9.2.17.0</version>
|
82
82
|
<type>pom</type>
|
83
83
|
</dependency>
|
84
84
|
<dependency>
|
@@ -49,21 +49,21 @@ public class FastNoiseModuleJava {
|
|
49
49
|
double four;
|
50
50
|
switch (args.length) {
|
51
51
|
case 2:
|
52
|
-
two =
|
53
|
-
one =
|
52
|
+
two = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
53
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
54
54
|
result = ng.noise2_XBeforeY(one, two);
|
55
55
|
break;
|
56
56
|
case 3:
|
57
|
-
three =
|
58
|
-
two =
|
59
|
-
one =
|
57
|
+
three = args[2] instanceof RubyFloat ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
|
58
|
+
two = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
59
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
60
60
|
result = ng.noise3_XYBeforeZ(one, two, three);
|
61
61
|
break;
|
62
62
|
case 4:
|
63
|
-
four =
|
64
|
-
three =
|
65
|
-
two =
|
66
|
-
one =
|
63
|
+
four = args[3] instanceof RubyFloat ? ((RubyFloat) args[3]).getValue() : ((RubyFixnum) args[3]).getDoubleValue();
|
64
|
+
three = args[2] instanceof RubyFloat ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
|
65
|
+
two = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
66
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
67
67
|
result = ng.noise4_XYBeforeZW(one, two, three, four);
|
68
68
|
break;
|
69
69
|
default:
|
@@ -88,25 +88,25 @@ public class FastNoiseModuleJava {
|
|
88
88
|
double four;
|
89
89
|
switch (args.length) {
|
90
90
|
case 1:
|
91
|
-
one =
|
91
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
92
92
|
result = ng.noise2(one, 0);
|
93
93
|
break;
|
94
94
|
case 2:
|
95
|
-
two =
|
96
|
-
one =
|
95
|
+
two = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
96
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
97
97
|
result = ng.noise2(one, two);
|
98
98
|
break;
|
99
99
|
case 3:
|
100
|
-
three =
|
101
|
-
two =
|
102
|
-
one =
|
100
|
+
three = args[2] instanceof RubyFloat ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
|
101
|
+
two = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
102
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
103
103
|
result = ng.noise3_Classic(one, two, three);
|
104
104
|
break;
|
105
105
|
case 4:
|
106
|
-
four =
|
107
|
-
three =
|
108
|
-
two =
|
109
|
-
one =
|
106
|
+
four = args[3] instanceof RubyFloat ? ((RubyFloat) args[3]).getValue() : ((RubyFixnum) args[3]).getDoubleValue();
|
107
|
+
three = args[2] instanceof RubyFloat ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
|
108
|
+
two = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
109
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
110
110
|
result = ng.noise4_Classic(one, two, three, four);
|
111
111
|
break;
|
112
112
|
default:
|
@@ -49,21 +49,21 @@ public class SmoothNoiseModuleJava {
|
|
49
49
|
double four;
|
50
50
|
switch (args.length) {
|
51
51
|
case 2:
|
52
|
-
two =
|
53
|
-
one =
|
52
|
+
two = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
53
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
54
54
|
result = ng.noise2_XBeforeY(one, two);
|
55
55
|
break;
|
56
56
|
case 3:
|
57
|
-
three =
|
58
|
-
two =
|
59
|
-
one =
|
57
|
+
three = args[2] instanceof RubyFloat ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
|
58
|
+
two = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
59
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
60
60
|
result = ng.noise3_XYBeforeZ(one, two, three);
|
61
61
|
break;
|
62
62
|
case 4:
|
63
|
-
four =
|
64
|
-
three =
|
65
|
-
two =
|
66
|
-
one =
|
63
|
+
four = args[3] instanceof RubyFloat ? ((RubyFloat) args[3]).getValue() : ((RubyFixnum) args[3]).getDoubleValue();
|
64
|
+
three = args[2] instanceof RubyFloat ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
|
65
|
+
two = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
66
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
67
67
|
result = ng.noise4_XYBeforeZW(one, two, three, four);
|
68
68
|
break;
|
69
69
|
default:
|
@@ -88,25 +88,25 @@ public class SmoothNoiseModuleJava {
|
|
88
88
|
double four;
|
89
89
|
switch (args.length) {
|
90
90
|
case 1:
|
91
|
-
one =
|
91
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
92
92
|
result = ng.noise2(one, 0);
|
93
93
|
break;
|
94
94
|
case 2:
|
95
|
-
two =
|
96
|
-
one =
|
95
|
+
two = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
96
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
97
97
|
result = ng.noise2(one, two);
|
98
98
|
break;
|
99
99
|
case 3:
|
100
|
-
three =
|
101
|
-
two =
|
102
|
-
one =
|
100
|
+
three = args[2] instanceof RubyFloat ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
|
101
|
+
two = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
102
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
103
103
|
result = ng.noise3_Classic(one, two, three);
|
104
104
|
break;
|
105
105
|
case 4:
|
106
|
-
four =
|
107
|
-
three =
|
108
|
-
two =
|
109
|
-
one =
|
106
|
+
four = args[3] instanceof RubyFloat ? ((RubyFloat) args[3]).getValue() : ((RubyFixnum) args[3]).getDoubleValue();
|
107
|
+
three = args[2] instanceof RubyFloat ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
|
108
|
+
two = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
109
|
+
one = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
110
110
|
result = ng.noise4_Classic(one, two, three, four);
|
111
111
|
break;
|
112
112
|
default:
|
@@ -1,813 +1,914 @@
|
|
1
1
|
package monkstone.noise;
|
2
|
+
|
2
3
|
/**
|
3
4
|
* K.jpg's OpenSimplex 2, faster variant
|
4
5
|
*
|
5
|
-
* - 2D is standard simplex implemented using a lookup table.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
* reciprocal. It successively finds the closest point on each.
|
6
|
+
* - 2D is standard simplex implemented using a lookup table. - 3D is
|
7
|
+
* "Re-oriented 4-point BCC noise" which constructs a congruent BCC lattice in a
|
8
|
+
* much different way than usual. - 4D constructs the lattice as a union of five
|
9
|
+
* copies of its reciprocal. It successively finds the closest point on each.
|
10
10
|
*
|
11
|
-
* Multiple versions of each function are provided. See the
|
12
|
-
*
|
11
|
+
* Multiple versions of each function are provided. See the documentation above
|
12
|
+
* each, for more info.
|
13
13
|
*/
|
14
14
|
public class OpenSimplex2F {
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
private static final int PSIZE = 2048;
|
17
|
+
private static final int PMASK = 2047;
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
private final short[] perm;
|
20
|
+
private final Grad2[] permGrad2;
|
21
|
+
private final Grad3[] permGrad3;
|
22
|
+
private final Grad4[] permGrad4;
|
23
23
|
|
24
24
|
/**
|
25
25
|
*
|
26
26
|
* @param seed
|
27
27
|
*/
|
28
28
|
public OpenSimplex2F(long seed) {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
29
|
+
perm = new short[PSIZE];
|
30
|
+
permGrad2 = new Grad2[PSIZE];
|
31
|
+
permGrad3 = new Grad3[PSIZE];
|
32
|
+
permGrad4 = new Grad4[PSIZE];
|
33
|
+
short[] source = new short[PSIZE];
|
34
|
+
for (short i = 0; i < PSIZE; i++) {
|
35
|
+
source[i] = i;
|
36
|
+
}
|
37
|
+
for (int i = PSIZE - 1; i >= 0; i--) {
|
38
|
+
seed = seed * 6364136223846793005L + 1442695040888963407L;
|
39
|
+
int r = (int) ((seed + 31) % (i + 1));
|
40
|
+
if (r < 0) {
|
41
|
+
r += i + 1;
|
42
|
+
}
|
43
|
+
perm[i] = source[r];
|
44
|
+
permGrad2[i] = GRADIENTS_2D[perm[i]];
|
45
|
+
permGrad3[i] = GRADIENTS_3D[perm[i]];
|
46
|
+
permGrad4[i] = GRADIENTS_4D[perm[i]];
|
47
|
+
source[r] = source[i];
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
/*
|
50
52
|
* Noise Evaluators
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
*/
|
54
|
+
/**
|
55
|
+
* 2D Simplex noise, standard lattice orientation.
|
56
|
+
*
|
55
57
|
* @param x
|
56
58
|
* @param y
|
57
|
-
* @return
|
58
|
-
|
59
|
-
|
59
|
+
* @return
|
60
|
+
*/
|
61
|
+
public double noise2(double x, double y) {
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
// Get points for A2* lattice
|
64
|
+
double s = 0.366025403784439 * (x + y);
|
65
|
+
double xs = x + s, ys = y + s;
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
+
return noise2_Base(xs, ys);
|
68
|
+
}
|
67
69
|
|
68
|
-
|
69
|
-
|
70
|
+
/**
|
71
|
+
* 2D Simplex noise, with Y pointing down the main diagonal.Might be better
|
72
|
+
* for a 2D sandbox style game, where Y is vertical.Probably slightly less
|
73
|
+
* optimal for heightmaps or continent maps.
|
74
|
+
*
|
70
75
|
* @param x
|
71
76
|
* @param y
|
72
|
-
* @return
|
73
|
-
|
74
|
-
|
77
|
+
* @return
|
78
|
+
*/
|
79
|
+
public double noise2_XBeforeY(double x, double y) {
|
75
80
|
|
76
|
-
|
77
|
-
|
78
|
-
|
81
|
+
// Skew transform and rotation baked into one.
|
82
|
+
double xx = x * 0.7071067811865476;
|
83
|
+
double yy = y * 1.224744871380249;
|
79
84
|
|
80
|
-
|
81
|
-
|
85
|
+
return noise2_Base(yy + xx, yy - xx);
|
86
|
+
}
|
82
87
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
88
|
+
/**
|
89
|
+
* 2D Simplex noise base. Lookup table implementation inspired by
|
90
|
+
* DigitalShadow.
|
91
|
+
*/
|
92
|
+
private double noise2_Base(double xs, double ys) {
|
93
|
+
double value = 0;
|
89
94
|
|
90
|
-
|
91
|
-
|
92
|
-
|
95
|
+
// Get base points and offsets
|
96
|
+
int xsb = fastFloor(xs), ysb = fastFloor(ys);
|
97
|
+
double xsi = xs - xsb, ysi = ys - ysb;
|
93
98
|
|
94
|
-
|
95
|
-
|
99
|
+
// Index to point list
|
100
|
+
int index = (int) ((ysi - xsi) / 2 + 1);
|
96
101
|
|
97
|
-
|
98
|
-
|
102
|
+
double ssi = (xsi + ysi) * -0.211324865405187;
|
103
|
+
double xi = xsi + ssi, yi = ysi + ssi;
|
99
104
|
|
100
|
-
|
101
|
-
|
102
|
-
|
105
|
+
// Point contributions
|
106
|
+
for (int i = 0; i < 3; i++) {
|
107
|
+
LatticePoint2D c = LOOKUP_2D[index + i];
|
103
108
|
|
104
|
-
|
105
|
-
|
106
|
-
|
109
|
+
double dx = xi + c.dx, dy = yi + c.dy;
|
110
|
+
double attn = 0.5 - dx * dx - dy * dy;
|
111
|
+
if (attn <= 0) {
|
112
|
+
continue;
|
113
|
+
}
|
107
114
|
|
108
|
-
|
109
|
-
|
110
|
-
|
115
|
+
int pxm = (xsb + c.xsv) & PMASK, pym = (ysb + c.ysv) & PMASK;
|
116
|
+
Grad2 grad = permGrad2[perm[pxm] ^ pym];
|
117
|
+
double extrapolation = grad.dx * dx + grad.dy * dy;
|
111
118
|
|
112
|
-
|
113
|
-
|
114
|
-
|
119
|
+
attn *= attn;
|
120
|
+
value += attn * attn * extrapolation;
|
121
|
+
}
|
115
122
|
|
116
|
-
|
117
|
-
|
123
|
+
return value;
|
124
|
+
}
|
118
125
|
|
119
|
-
|
120
|
-
|
126
|
+
/**
|
127
|
+
* 3D Re-oriented 4-point BCC noise, classic orientation.Proper substitute
|
128
|
+
* for 3D Simplex in light of Forbidden Formulae.Use noise3_XYBeforeZ or
|
129
|
+
* noise3_XZBeforeY instead, wherever appropriate.
|
130
|
+
*
|
121
131
|
* @param x
|
122
132
|
* @param y
|
123
133
|
* @param z
|
124
|
-
* @return
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
134
|
+
* @return
|
135
|
+
*/
|
136
|
+
public double noise3_Classic(double x, double y, double z) {
|
137
|
+
|
138
|
+
// Re-orient the cubic lattices via rotation, to produce the expected look on cardinal planar slices.
|
139
|
+
// If texturing objects that don't tend to have cardinal plane faces, you could even remove this.
|
140
|
+
// Orthonormal rotation. Not a skew transform.
|
141
|
+
double r = (2.0 / 3.0) * (x + y + z);
|
142
|
+
double xr = r - x, yr = r - y, zr = r - z;
|
143
|
+
|
144
|
+
// Evaluate both lattices to form a BCC lattice.
|
145
|
+
return noise3_BCC(xr, yr, zr);
|
146
|
+
}
|
147
|
+
|
148
|
+
/**
|
149
|
+
* 3D Re-oriented 4-point BCC noise, with better visual isotropy in (X,
|
150
|
+
* Y).Recommended for 3D terrain and time-varied animations.The Z coordinate
|
151
|
+
* should always be the "different" coordinate in your use case.If Y is
|
152
|
+
* vertical in world coordinates, call noise3_XYBeforeZ(x, z, Y) or use
|
153
|
+
* noise3_XZBeforeY.If Z is vertical in world coordinates, call
|
154
|
+
* noise3_XYBeforeZ(x, y, Z). For a time varied animation, call
|
155
|
+
* noise3_XYBeforeZ(x, y, T).
|
156
|
+
*
|
141
157
|
* @param x
|
142
158
|
* @param y
|
143
159
|
* @param z
|
144
|
-
* @return
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
160
|
+
* @return
|
161
|
+
*/
|
162
|
+
public double noise3_XYBeforeZ(double x, double y, double z) {
|
163
|
+
|
164
|
+
// Re-orient the cubic lattices without skewing, to make X and Y triangular like 2D.
|
165
|
+
// Orthonormal rotation. Not a skew transform.
|
166
|
+
double xy = x + y;
|
167
|
+
double s2 = xy * -0.211324865405187;
|
168
|
+
double zz = z * 0.577350269189626;
|
169
|
+
double xr = x + s2 - zz, yr = y + s2 - zz;
|
170
|
+
double zr = xy * 0.577350269189626 + zz;
|
171
|
+
|
172
|
+
// Evaluate both lattices to form a BCC lattice.
|
173
|
+
return noise3_BCC(xr, yr, zr);
|
174
|
+
}
|
175
|
+
|
176
|
+
/**
|
177
|
+
* 3D Re-oriented 4-point BCC noise, with better visual isotropy in (X,
|
178
|
+
* Z).Recommended for 3D terrain and time-varied animations.The Y coordinate
|
179
|
+
* should always be the "different" coordinate in your use case.If Y is
|
180
|
+
* vertical in world coordinates, call noise3_XZBeforeY(x, Y, z).If Z is
|
181
|
+
* vertical in world coordinates, call noise3_XZBeforeY(x, Z, y) or use
|
182
|
+
* noise3_XYBeforeZ. For a time varied animation, call noise3_XZBeforeY(x,
|
183
|
+
* T, y) or use noise3_XYBeforeZ.
|
184
|
+
*
|
163
185
|
* @param x
|
164
186
|
* @param y
|
165
187
|
* @param z
|
166
|
-
* @return
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
188
|
+
* @return
|
189
|
+
*/
|
190
|
+
public double noise3_XZBeforeY(double x, double y, double z) {
|
191
|
+
|
192
|
+
// Re-orient the cubic lattices without skewing, to make X and Z triangular like 2D.
|
193
|
+
// Orthonormal rotation. Not a skew transform.
|
194
|
+
double xz = x + z;
|
195
|
+
double s2 = xz * -0.211324865405187;
|
196
|
+
double yy = y * 0.577350269189626;
|
197
|
+
double xr = x + s2 - yy;
|
198
|
+
double zr = z + s2 - yy;
|
199
|
+
double yr = xz * 0.577350269189626 + yy;
|
200
|
+
|
201
|
+
// Evaluate both lattices to form a BCC lattice.
|
202
|
+
return noise3_BCC(xr, yr, zr);
|
203
|
+
}
|
204
|
+
|
205
|
+
/**
|
206
|
+
* Generate overlapping cubic lattices for 3D Re-oriented BCC noise. Lookup
|
207
|
+
* table implementation inspired by DigitalShadow. It was actually faster to
|
208
|
+
* narrow down the points in the loop itself, than to build up the index
|
209
|
+
* with enough info to isolate 4 points.
|
210
|
+
*/
|
211
|
+
private double noise3_BCC(double xr, double yr, double zr) {
|
212
|
+
|
213
|
+
// Get base and offsets inside cube of first lattice.
|
214
|
+
int xrb = fastFloor(xr), yrb = fastFloor(yr), zrb = fastFloor(zr);
|
215
|
+
double xri = xr - xrb, yri = yr - yrb, zri = zr - zrb;
|
216
|
+
|
217
|
+
// Identify which octant of the cube we're in. This determines which cell
|
218
|
+
// in the other cubic lattice we're in, and also narrows down one point on each.
|
219
|
+
int xht = (int) (xri + 0.5), yht = (int) (yri + 0.5), zht = (int) (zri + 0.5);
|
220
|
+
int index = (xht) | (yht << 1) | (zht << 2);
|
221
|
+
|
222
|
+
// Point contributions
|
223
|
+
double value = 0;
|
224
|
+
LatticePoint3D c = LOOKUP_3D[index];
|
225
|
+
while (c != null) {
|
226
|
+
double dxr = xri + c.dxr, dyr = yri + c.dyr, dzr = zri + c.dzr;
|
227
|
+
double attn = 0.5 - dxr * dxr - dyr * dyr - dzr * dzr;
|
228
|
+
if (attn < 0) {
|
229
|
+
c = c.nextOnFailure;
|
230
|
+
} else {
|
231
|
+
int pxm = (xrb + c.xrv) & PMASK, pym = (yrb + c.yrv) & PMASK, pzm = (zrb + c.zrv) & PMASK;
|
232
|
+
Grad3 grad = permGrad3[perm[perm[pxm] ^ pym] ^ pzm];
|
233
|
+
double extrapolation = grad.dx * dxr + grad.dy * dyr + grad.dz * dzr;
|
234
|
+
|
235
|
+
attn *= attn;
|
236
|
+
value += attn * attn * extrapolation;
|
237
|
+
c = c.nextOnSuccess;
|
238
|
+
}
|
239
|
+
}
|
240
|
+
return value;
|
241
|
+
}
|
242
|
+
|
243
|
+
/**
|
244
|
+
* 4D OpenSimplex2F noise, classic lattice orientation.
|
245
|
+
*
|
222
246
|
* @param x
|
223
247
|
* @param y
|
224
248
|
* @param w
|
225
249
|
* @param z
|
226
|
-
* @return
|
227
|
-
|
228
|
-
|
250
|
+
* @return
|
251
|
+
*/
|
252
|
+
public double noise4_Classic(double x, double y, double z, double w) {
|
229
253
|
|
230
|
-
|
231
|
-
|
232
|
-
|
254
|
+
// Get points for A4 lattice
|
255
|
+
double s = -0.138196601125011 * (x + y + z + w);
|
256
|
+
double xs = x + s, ys = y + s, zs = z + s, ws = w + s;
|
233
257
|
|
234
|
-
|
235
|
-
|
258
|
+
return noise4_Base(xs, ys, zs, ws);
|
259
|
+
}
|
236
260
|
|
237
|
-
|
238
|
-
|
261
|
+
/**
|
262
|
+
* 4D OpenSimplex2F noise, with XY and ZW forming orthogonal
|
263
|
+
* triangular-based planes.Recommended for 3D terrain, where X and Y (or Z
|
264
|
+
* and W) are horizontal.Recommended for noise(x, y, sin(time), cos(time))
|
265
|
+
* trick.
|
266
|
+
*
|
239
267
|
* @param x
|
240
268
|
* @param z
|
241
269
|
* @param y
|
242
270
|
* @param w
|
243
|
-
* @return
|
244
|
-
|
245
|
-
|
271
|
+
* @return
|
272
|
+
*/
|
273
|
+
public double noise4_XYBeforeZW(double x, double y, double z, double w) {
|
246
274
|
|
247
|
-
|
248
|
-
|
249
|
-
|
275
|
+
double s2 = (x + y) * -0.178275657951399372 + (z + w) * 0.215623393288842828;
|
276
|
+
double t2 = (z + w) * -0.403949762580207112 + (x + y) * -0.375199083010075342;
|
277
|
+
double xs = x + s2, ys = y + s2, zs = z + t2, ws = w + t2;
|
250
278
|
|
251
|
-
|
252
|
-
|
279
|
+
return noise4_Base(xs, ys, zs, ws);
|
280
|
+
}
|
253
281
|
|
254
|
-
|
255
|
-
|
282
|
+
/**
|
283
|
+
* 4D OpenSimplex2F noise, with XZ and YW forming orthogonal
|
284
|
+
* triangular-based planes.Recommended for 3D terrain, where X and Z (or Y
|
285
|
+
* and W) are horizontal.
|
286
|
+
*
|
256
287
|
* @param x
|
257
288
|
* @param z
|
258
289
|
* @param y
|
259
290
|
* @param w
|
260
|
-
* @return
|
261
|
-
|
262
|
-
|
291
|
+
* @return
|
292
|
+
*/
|
293
|
+
public double noise4_XZBeforeYW(double x, double y, double z, double w) {
|
263
294
|
|
264
|
-
|
265
|
-
|
266
|
-
|
295
|
+
double s2 = (x + z) * -0.178275657951399372 + (y + w) * 0.215623393288842828;
|
296
|
+
double t2 = (y + w) * -0.403949762580207112 + (x + z) * -0.375199083010075342;
|
297
|
+
double xs = x + s2, ys = y + t2, zs = z + s2, ws = w + t2;
|
267
298
|
|
268
|
-
|
269
|
-
|
299
|
+
return noise4_Base(xs, ys, zs, ws);
|
300
|
+
}
|
270
301
|
|
271
|
-
|
272
|
-
|
273
|
-
|
302
|
+
/**
|
303
|
+
* 4D OpenSimplex2F noise, with XYZ oriented like noise3_Classic, and W for
|
304
|
+
* an extra degree of freedom.W repeats eventually.Recommended for
|
305
|
+
* time-varied animations which texture a 3D object (W=time)
|
306
|
+
*
|
274
307
|
* @param x
|
275
308
|
* @param w
|
276
309
|
* @param y
|
277
310
|
* @param z
|
278
311
|
* @return
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
double xyz = x + y + z;
|
283
|
-
double ww = w * 0.2236067977499788;
|
284
|
-
double s2 = xyz * -0.16666666666666666 + ww;
|
285
|
-
double xs = x + s2, ys = y + s2, zs = z + s2, ws = -0.5 * xyz + ww;
|
286
|
-
|
287
|
-
return noise4_Base(xs, ys, zs, ws);
|
288
|
-
}
|
289
|
-
|
290
|
-
/**
|
291
|
-
* 4D OpenSimplex2F noise base.
|
292
|
-
* Current implementation not fully optimized by lookup tables.
|
293
|
-
* But still comes out slightly ahead of Gustavson's Simplex in tests.
|
294
|
-
*/
|
295
|
-
private double noise4_Base(double xs, double ys, double zs, double ws) {
|
296
|
-
double value = 0;
|
297
|
-
|
298
|
-
// Get base points and offsets
|
299
|
-
int xsb = fastFloor(xs), ysb = fastFloor(ys), zsb = fastFloor(zs), wsb = fastFloor(ws);
|
300
|
-
double xsi = xs - xsb, ysi = ys - ysb, zsi = zs - zsb, wsi = ws - wsb;
|
301
|
-
|
302
|
-
// If we're in the lower half, flip so we can repeat the code for the upper half. We'll flip back later.
|
303
|
-
double siSum = xsi + ysi + zsi + wsi;
|
304
|
-
double ssi = siSum * 0.309016994374947; // Prep for vertex contributions.
|
305
|
-
boolean inLowerHalf = (siSum < 2);
|
306
|
-
if (inLowerHalf) {
|
307
|
-
xsi = 1 - xsi; ysi = 1 - ysi; zsi = 1 - zsi; wsi = 1 - wsi;
|
308
|
-
siSum = 4 - siSum;
|
309
|
-
}
|
310
|
-
|
311
|
-
// Consider opposing vertex pairs of the octahedron formed by the central cross-section of the stretched tesseract
|
312
|
-
double aabb = xsi + ysi - zsi - wsi, abab = xsi - ysi + zsi - wsi, abba = xsi - ysi - zsi + wsi;
|
313
|
-
double aabbScore = Math.abs(aabb), ababScore = Math.abs(abab), abbaScore = Math.abs(abba);
|
314
|
-
|
315
|
-
// Find the closest point on the stretched tesseract as if it were the upper half
|
316
|
-
int vertexIndex, via, vib;
|
317
|
-
double asi, bsi;
|
318
|
-
if (aabbScore > ababScore && aabbScore > abbaScore) {
|
319
|
-
if (aabb > 0) {
|
320
|
-
asi = zsi; bsi = wsi; vertexIndex = 0b0011; via = 0b0111; vib = 0b1011;
|
321
|
-
} else {
|
322
|
-
asi = xsi; bsi = ysi; vertexIndex = 0b1100; via = 0b1101; vib = 0b1110;
|
323
|
-
}
|
324
|
-
} else if (ababScore > abbaScore) {
|
325
|
-
if (abab > 0) {
|
326
|
-
asi = ysi; bsi = wsi; vertexIndex = 0b0101; via = 0b0111; vib = 0b1101;
|
327
|
-
} else {
|
328
|
-
asi = xsi; bsi = zsi; vertexIndex = 0b1010; via = 0b1011; vib = 0b1110;
|
329
|
-
}
|
330
|
-
} else {
|
331
|
-
if (abba > 0) {
|
332
|
-
asi = ysi; bsi = zsi; vertexIndex = 0b1001; via = 0b1011; vib = 0b1101;
|
333
|
-
} else {
|
334
|
-
asi = xsi; bsi = wsi; vertexIndex = 0b0110; via = 0b0111; vib = 0b1110;
|
335
|
-
}
|
336
|
-
}
|
337
|
-
if (bsi > asi) {
|
338
|
-
via = vib;
|
339
|
-
double temp = bsi;
|
340
|
-
bsi = asi;
|
341
|
-
asi = temp;
|
342
|
-
}
|
343
|
-
if (siSum + asi > 3) {
|
344
|
-
vertexIndex = via;
|
345
|
-
if (siSum + bsi > 4) {
|
346
|
-
vertexIndex = 0b1111;
|
347
|
-
}
|
348
|
-
}
|
349
|
-
|
350
|
-
// Now flip back if we're actually in the lower half.
|
351
|
-
if (inLowerHalf) {
|
352
|
-
xsi = 1 - xsi; ysi = 1 - ysi; zsi = 1 - zsi; wsi = 1 - wsi;
|
353
|
-
vertexIndex ^= 0b1111;
|
354
|
-
}
|
355
|
-
|
356
|
-
// Five points to add, total, from five copies of the A4 lattice.
|
357
|
-
for (int i = 0; i < 5; i++) {
|
358
|
-
|
359
|
-
// Update xsb/etc. and add the lattice point's contribution.
|
360
|
-
LatticePoint4D c = VERTICES_4D[vertexIndex];
|
361
|
-
xsb += c.xsv; ysb += c.ysv; zsb += c.zsv; wsb += c.wsv;
|
362
|
-
double xi = xsi + ssi, yi = ysi + ssi, zi = zsi + ssi, wi = wsi + ssi;
|
363
|
-
double dx = xi + c.dx, dy = yi + c.dy, dz = zi + c.dz, dw = wi + c.dw;
|
364
|
-
double attn = 0.5 - dx * dx - dy * dy - dz * dz - dw * dw;
|
365
|
-
if (attn > 0) {
|
366
|
-
int pxm = xsb & PMASK, pym = ysb & PMASK, pzm = zsb & PMASK, pwm = wsb & PMASK;
|
367
|
-
Grad4 grad = permGrad4[perm[perm[perm[pxm] ^ pym] ^ pzm] ^ pwm];
|
368
|
-
double ramped = grad.dx * dx + grad.dy * dy + grad.dz * dz + grad.dw * dw;
|
369
|
-
|
370
|
-
attn *= attn;
|
371
|
-
value += attn * attn * ramped;
|
372
|
-
}
|
373
|
-
|
374
|
-
// Maybe this helps the compiler/JVM/LLVM/etc. know we can end the loop here. Maybe not.
|
375
|
-
if (i == 4) break;
|
376
|
-
|
377
|
-
// Update the relative skewed coordinates to reference the vertex we just added.
|
378
|
-
// Rather, reference its counterpart on the lattice copy that is shifted down by
|
379
|
-
// the vector <-0.2, -0.2, -0.2, -0.2>
|
380
|
-
xsi += c.xsi; ysi += c.ysi; zsi += c.zsi; wsi += c.wsi;
|
381
|
-
ssi += c.ssiDelta;
|
382
|
-
|
383
|
-
// Next point is the closest vertex on the 4-simplex whose base vertex is the aforementioned vertex.
|
384
|
-
double score0 = 1.0 + ssi * (-1.0 / 0.309016994374947); // Seems slightly faster than 1.0-xsi-ysi-zsi-wsi
|
385
|
-
vertexIndex = 0b0000;
|
386
|
-
if (xsi >= ysi && xsi >= zsi && xsi >= wsi && xsi >= score0) {
|
387
|
-
vertexIndex = 0b0001;
|
388
|
-
}
|
389
|
-
else if (ysi > xsi && ysi >= zsi && ysi >= wsi && ysi >= score0) {
|
390
|
-
vertexIndex = 0b0010;
|
391
|
-
}
|
392
|
-
else if (zsi > xsi && zsi > ysi && zsi >= wsi && zsi >= score0) {
|
393
|
-
vertexIndex = 0b0100;
|
394
|
-
}
|
395
|
-
else if (wsi > xsi && wsi > ysi && wsi > zsi && wsi >= score0) {
|
396
|
-
vertexIndex = 0b1000;
|
397
|
-
}
|
398
|
-
}
|
399
|
-
|
400
|
-
return value;
|
401
|
-
}
|
402
|
-
|
403
|
-
/*
|
404
|
-
* Utility
|
405
|
-
*/
|
312
|
+
*/
|
313
|
+
public double noise4_XYZBeforeW(double x, double y, double z, double w) {
|
406
314
|
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
315
|
+
double xyz = x + y + z;
|
316
|
+
double ww = w * 0.2236067977499788;
|
317
|
+
double s2 = xyz * -0.16666666666666666 + ww;
|
318
|
+
double xs = x + s2, ys = y + s2, zs = z + s2, ws = -0.5 * xyz + ww;
|
411
319
|
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
double dx, dy;
|
474
|
-
public LatticePoint2D(int xsv, int ysv) {
|
475
|
-
this.xsv = xsv; this.ysv = ysv;
|
476
|
-
double ssv = (xsv + ysv) * -0.211324865405187;
|
477
|
-
this.dx = -xsv - ssv;
|
478
|
-
this.dy = -ysv - ssv;
|
479
|
-
}
|
480
|
-
}
|
481
|
-
|
482
|
-
private static class LatticePoint3D {
|
483
|
-
public double dxr, dyr, dzr;
|
484
|
-
public int xrv, yrv, zrv;
|
485
|
-
LatticePoint3D nextOnFailure, nextOnSuccess;
|
486
|
-
public LatticePoint3D(int xrv, int yrv, int zrv, int lattice) {
|
487
|
-
this.dxr = -xrv + lattice * 0.5; this.dyr = -yrv + lattice * 0.5; this.dzr = -zrv + lattice * 0.5;
|
488
|
-
this.xrv = xrv + lattice * 1024; this.yrv = yrv + lattice * 1024; this.zrv = zrv + lattice * 1024;
|
489
|
-
}
|
490
|
-
}
|
491
|
-
|
492
|
-
private static class LatticePoint4D {
|
493
|
-
int xsv, ysv, zsv, wsv;
|
494
|
-
double dx, dy, dz, dw;
|
495
|
-
double xsi, ysi, zsi, wsi;
|
496
|
-
double ssiDelta;
|
497
|
-
public LatticePoint4D(int xsv, int ysv, int zsv, int wsv) {
|
498
|
-
this.xsv = xsv + 409; this.ysv = ysv + 409; this.zsv = zsv + 409; this.wsv = wsv + 409;
|
499
|
-
double ssv = (xsv + ysv + zsv + wsv) * 0.309016994374947;
|
500
|
-
this.dx = -xsv - ssv;
|
501
|
-
this.dy = -ysv - ssv;
|
502
|
-
this.dz = -zsv - ssv;
|
503
|
-
this.dw = -wsv - ssv;
|
504
|
-
this.xsi = xsi = 0.2 - xsv;
|
505
|
-
this.ysi = ysi = 0.2 - ysv;
|
506
|
-
this.zsi = zsi = 0.2 - zsv;
|
507
|
-
this.wsi = wsi = 0.2 - wsv;
|
508
|
-
this.ssiDelta = (0.8 - xsv - ysv - zsv - wsv) * 0.309016994374947;
|
509
|
-
}
|
510
|
-
}
|
511
|
-
|
512
|
-
/*
|
513
|
-
* Gradients
|
514
|
-
*/
|
515
|
-
|
516
|
-
private static class Grad2 {
|
517
|
-
double dx, dy;
|
518
|
-
public Grad2(double dx, double dy) {
|
519
|
-
this.dx = dx; this.dy = dy;
|
520
|
-
}
|
521
|
-
}
|
522
|
-
|
523
|
-
private static class Grad3 {
|
524
|
-
double dx, dy, dz;
|
525
|
-
public Grad3(double dx, double dy, double dz) {
|
526
|
-
this.dx = dx; this.dy = dy; this.dz = dz;
|
527
|
-
}
|
528
|
-
}
|
529
|
-
|
530
|
-
private static class Grad4 {
|
531
|
-
double dx, dy, dz, dw;
|
532
|
-
public Grad4(double dx, double dy, double dz, double dw) {
|
533
|
-
this.dx = dx; this.dy = dy; this.dz = dz; this.dw = dw;
|
534
|
-
}
|
535
|
-
}
|
536
|
-
|
537
|
-
private static final double N2 = 0.01001634121365712;
|
538
|
-
private static final double N3 = 0.030485933181293584;
|
539
|
-
private static final double N4 = 0.009202377986303158;
|
540
|
-
private static final Grad2[] GRADIENTS_2D;
|
541
|
-
private static final Grad3[] GRADIENTS_3D;
|
542
|
-
private static final Grad4[] GRADIENTS_4D;
|
543
|
-
static {
|
544
|
-
|
545
|
-
GRADIENTS_2D = new Grad2[PSIZE];
|
546
|
-
Grad2[] grad2 = {
|
547
|
-
new Grad2( 0.130526192220052, 0.99144486137381),
|
548
|
-
new Grad2( 0.38268343236509, 0.923879532511287),
|
549
|
-
new Grad2( 0.608761429008721, 0.793353340291235),
|
550
|
-
new Grad2( 0.793353340291235, 0.608761429008721),
|
551
|
-
new Grad2( 0.923879532511287, 0.38268343236509),
|
552
|
-
new Grad2( 0.99144486137381, 0.130526192220051),
|
553
|
-
new Grad2( 0.99144486137381, -0.130526192220051),
|
554
|
-
new Grad2( 0.923879532511287, -0.38268343236509),
|
555
|
-
new Grad2( 0.793353340291235, -0.60876142900872),
|
556
|
-
new Grad2( 0.608761429008721, -0.793353340291235),
|
557
|
-
new Grad2( 0.38268343236509, -0.923879532511287),
|
558
|
-
new Grad2( 0.130526192220052, -0.99144486137381),
|
559
|
-
new Grad2(-0.130526192220052, -0.99144486137381),
|
560
|
-
new Grad2(-0.38268343236509, -0.923879532511287),
|
561
|
-
new Grad2(-0.608761429008721, -0.793353340291235),
|
562
|
-
new Grad2(-0.793353340291235, -0.608761429008721),
|
563
|
-
new Grad2(-0.923879532511287, -0.38268343236509),
|
564
|
-
new Grad2(-0.99144486137381, -0.130526192220052),
|
565
|
-
new Grad2(-0.99144486137381, 0.130526192220051),
|
566
|
-
new Grad2(-0.923879532511287, 0.38268343236509),
|
567
|
-
new Grad2(-0.793353340291235, 0.608761429008721),
|
568
|
-
new Grad2(-0.608761429008721, 0.793353340291235),
|
569
|
-
new Grad2(-0.38268343236509, 0.923879532511287),
|
570
|
-
new Grad2(-0.130526192220052, 0.99144486137381)
|
571
|
-
};
|
572
|
-
for (Grad2 grad21 : grad2) {
|
573
|
-
grad21.dx /= N2;
|
574
|
-
grad21.dy /= N2;
|
320
|
+
return noise4_Base(xs, ys, zs, ws);
|
321
|
+
}
|
322
|
+
|
323
|
+
/**
|
324
|
+
* 4D OpenSimplex2F noise base. Current implementation not fully optimized
|
325
|
+
* by lookup tables. But still comes out slightly ahead of Gustavson's
|
326
|
+
* Simplex in tests.
|
327
|
+
*/
|
328
|
+
private double noise4_Base(double xs, double ys, double zs, double ws) {
|
329
|
+
double value = 0;
|
330
|
+
|
331
|
+
// Get base points and offsets
|
332
|
+
int xsb = fastFloor(xs), ysb = fastFloor(ys), zsb = fastFloor(zs), wsb = fastFloor(ws);
|
333
|
+
double xsi = xs - xsb, ysi = ys - ysb, zsi = zs - zsb, wsi = ws - wsb;
|
334
|
+
|
335
|
+
// If we're in the lower half, flip so we can repeat the code for the upper half. We'll flip back later.
|
336
|
+
double siSum = xsi + ysi + zsi + wsi;
|
337
|
+
double ssi = siSum * 0.309016994374947; // Prep for vertex contributions.
|
338
|
+
boolean inLowerHalf = siSum < 2;
|
339
|
+
if (inLowerHalf) {
|
340
|
+
xsi = 1 - xsi;
|
341
|
+
ysi = 1 - ysi;
|
342
|
+
zsi = 1 - zsi;
|
343
|
+
wsi = 1 - wsi;
|
344
|
+
siSum = 4 - siSum;
|
345
|
+
}
|
346
|
+
|
347
|
+
// Consider opposing vertex pairs of the octahedron formed by the central cross-section of the stretched tesseract
|
348
|
+
double aabb = xsi + ysi - zsi - wsi, abab = xsi - ysi + zsi - wsi, abba = xsi - ysi - zsi + wsi;
|
349
|
+
double aabbScore = Math.abs(aabb), ababScore = Math.abs(abab), abbaScore = Math.abs(abba);
|
350
|
+
|
351
|
+
// Find the closest point on the stretched tesseract as if it were the upper half
|
352
|
+
int vertexIndex, via, vib;
|
353
|
+
double asi, bsi;
|
354
|
+
if (aabbScore > ababScore && aabbScore > abbaScore) {
|
355
|
+
if (aabb > 0) {
|
356
|
+
asi = zsi;
|
357
|
+
bsi = wsi;
|
358
|
+
vertexIndex = 0b0011;
|
359
|
+
via = 0b0111;
|
360
|
+
vib = 0b1011;
|
361
|
+
} else {
|
362
|
+
asi = xsi;
|
363
|
+
bsi = ysi;
|
364
|
+
vertexIndex = 0b1100;
|
365
|
+
via = 0b1101;
|
366
|
+
vib = 0b1110;
|
367
|
+
}
|
368
|
+
} else if (ababScore > abbaScore) {
|
369
|
+
if (abab > 0) {
|
370
|
+
asi = ysi;
|
371
|
+
bsi = wsi;
|
372
|
+
vertexIndex = 0b0101;
|
373
|
+
via = 0b0111;
|
374
|
+
vib = 0b1101;
|
375
|
+
} else {
|
376
|
+
asi = xsi;
|
377
|
+
bsi = zsi;
|
378
|
+
vertexIndex = 0b1010;
|
379
|
+
via = 0b1011;
|
380
|
+
vib = 0b1110;
|
575
381
|
}
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
new Grad3(-3.0862664687972017, 0.0, -1.1721513422464978),
|
590
|
-
new Grad3(-2.22474487139, -1.0, 2.22474487139),
|
591
|
-
new Grad3(-2.22474487139, 1.0, 2.22474487139),
|
592
|
-
new Grad3(-3.0862664687972017, 0.0, 1.1721513422464978),
|
593
|
-
new Grad3(-1.1721513422464978, 0.0, 3.0862664687972017),
|
594
|
-
new Grad3(-2.22474487139, 2.22474487139, -1.0),
|
595
|
-
new Grad3(-2.22474487139, 2.22474487139, 1.0),
|
596
|
-
new Grad3(-1.1721513422464978, 3.0862664687972017, 0.0),
|
597
|
-
new Grad3(-3.0862664687972017, 1.1721513422464978, 0.0),
|
598
|
-
new Grad3(-1.0, -2.22474487139, -2.22474487139),
|
599
|
-
new Grad3( 1.0, -2.22474487139, -2.22474487139),
|
600
|
-
new Grad3( 0.0, -3.0862664687972017, -1.1721513422464978),
|
601
|
-
new Grad3( 0.0, -1.1721513422464978, -3.0862664687972017),
|
602
|
-
new Grad3(-1.0, -2.22474487139, 2.22474487139),
|
603
|
-
new Grad3( 1.0, -2.22474487139, 2.22474487139),
|
604
|
-
new Grad3( 0.0, -1.1721513422464978, 3.0862664687972017),
|
605
|
-
new Grad3( 0.0, -3.0862664687972017, 1.1721513422464978),
|
606
|
-
new Grad3(-1.0, 2.22474487139, -2.22474487139),
|
607
|
-
new Grad3( 1.0, 2.22474487139, -2.22474487139),
|
608
|
-
new Grad3( 0.0, 1.1721513422464978, -3.0862664687972017),
|
609
|
-
new Grad3( 0.0, 3.0862664687972017, -1.1721513422464978),
|
610
|
-
new Grad3(-1.0, 2.22474487139, 2.22474487139),
|
611
|
-
new Grad3( 1.0, 2.22474487139, 2.22474487139),
|
612
|
-
new Grad3( 0.0, 3.0862664687972017, 1.1721513422464978),
|
613
|
-
new Grad3( 0.0, 1.1721513422464978, 3.0862664687972017),
|
614
|
-
new Grad3( 2.22474487139, -2.22474487139, -1.0),
|
615
|
-
new Grad3( 2.22474487139, -2.22474487139, 1.0),
|
616
|
-
new Grad3( 1.1721513422464978, -3.0862664687972017, 0.0),
|
617
|
-
new Grad3( 3.0862664687972017, -1.1721513422464978, 0.0),
|
618
|
-
new Grad3( 2.22474487139, -1.0, -2.22474487139),
|
619
|
-
new Grad3( 2.22474487139, 1.0, -2.22474487139),
|
620
|
-
new Grad3( 3.0862664687972017, 0.0, -1.1721513422464978),
|
621
|
-
new Grad3( 1.1721513422464978, 0.0, -3.0862664687972017),
|
622
|
-
new Grad3( 2.22474487139, -1.0, 2.22474487139),
|
623
|
-
new Grad3( 2.22474487139, 1.0, 2.22474487139),
|
624
|
-
new Grad3( 1.1721513422464978, 0.0, 3.0862664687972017),
|
625
|
-
new Grad3( 3.0862664687972017, 0.0, 1.1721513422464978),
|
626
|
-
new Grad3( 2.22474487139, 2.22474487139, -1.0),
|
627
|
-
new Grad3( 2.22474487139, 2.22474487139, 1.0),
|
628
|
-
new Grad3( 3.0862664687972017, 1.1721513422464978, 0.0),
|
629
|
-
new Grad3( 1.1721513422464978, 3.0862664687972017, 0.0)
|
630
|
-
};
|
631
|
-
for (Grad3 grad31 : grad3) {
|
632
|
-
grad31.dx /= N3;
|
633
|
-
grad31.dy /= N3;
|
634
|
-
grad31.dz /= N3;
|
382
|
+
} else {
|
383
|
+
if (abba > 0) {
|
384
|
+
asi = ysi;
|
385
|
+
bsi = zsi;
|
386
|
+
vertexIndex = 0b1001;
|
387
|
+
via = 0b1011;
|
388
|
+
vib = 0b1101;
|
389
|
+
} else {
|
390
|
+
asi = xsi;
|
391
|
+
bsi = wsi;
|
392
|
+
vertexIndex = 0b0110;
|
393
|
+
via = 0b0111;
|
394
|
+
vib = 0b1110;
|
635
395
|
}
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
new Grad4(-0.5794684678643381, 0.3239847771997537, 0.6740059517812944, 0.3239847771997537),
|
706
|
-
new Grad4(-0.3239847771997537, -0.6740059517812944, 0.5794684678643381, -0.3239847771997537),
|
707
|
-
new Grad4(-0.4004672082940195, -0.7504883828755602, 0.5029860367700724, 0.15296486218853164),
|
708
|
-
new Grad4( 0.15296486218853164, -0.7504883828755602, 0.5029860367700724, -0.4004672082940195),
|
709
|
-
new Grad4( 0.08164729285680945, -0.8828161875373585, 0.4553054119602712, 0.08164729285680945),
|
710
|
-
new Grad4(-0.08164729285680945, -0.4553054119602712, 0.8828161875373585, -0.08164729285680945),
|
711
|
-
new Grad4(-0.15296486218853164, -0.5029860367700724, 0.7504883828755602, 0.4004672082940195),
|
712
|
-
new Grad4( 0.4004672082940195, -0.5029860367700724, 0.7504883828755602, -0.15296486218853164),
|
713
|
-
new Grad4( 0.3239847771997537, -0.5794684678643381, 0.6740059517812944, 0.3239847771997537),
|
714
|
-
new Grad4(-0.3239847771997537, -0.3239847771997537, 0.5794684678643381, -0.6740059517812944),
|
715
|
-
new Grad4(-0.4004672082940195, 0.15296486218853164, 0.5029860367700724, -0.7504883828755602),
|
716
|
-
new Grad4( 0.15296486218853164, -0.4004672082940195, 0.5029860367700724, -0.7504883828755602),
|
717
|
-
new Grad4( 0.08164729285680945, 0.08164729285680945, 0.4553054119602712, -0.8828161875373585),
|
718
|
-
new Grad4(-0.08164729285680945, -0.08164729285680945, 0.8828161875373585, -0.4553054119602712),
|
719
|
-
new Grad4(-0.15296486218853164, 0.4004672082940195, 0.7504883828755602, -0.5029860367700724),
|
720
|
-
new Grad4( 0.4004672082940195, -0.15296486218853164, 0.7504883828755602, -0.5029860367700724),
|
721
|
-
new Grad4( 0.3239847771997537, 0.3239847771997537, 0.6740059517812944, -0.5794684678643381),
|
722
|
-
new Grad4(-0.6740059517812944, 0.5794684678643381, -0.3239847771997537, -0.3239847771997537),
|
723
|
-
new Grad4(-0.7504883828755602, 0.5029860367700724, -0.4004672082940195, 0.15296486218853164),
|
724
|
-
new Grad4(-0.7504883828755602, 0.5029860367700724, 0.15296486218853164, -0.4004672082940195),
|
725
|
-
new Grad4(-0.8828161875373585, 0.4553054119602712, 0.08164729285680945, 0.08164729285680945),
|
726
|
-
new Grad4(-0.4553054119602712, 0.8828161875373585, -0.08164729285680945, -0.08164729285680945),
|
727
|
-
new Grad4(-0.5029860367700724, 0.7504883828755602, -0.15296486218853164, 0.4004672082940195),
|
728
|
-
new Grad4(-0.5029860367700724, 0.7504883828755602, 0.4004672082940195, -0.15296486218853164),
|
729
|
-
new Grad4(-0.5794684678643381, 0.6740059517812944, 0.3239847771997537, 0.3239847771997537),
|
730
|
-
new Grad4(-0.3239847771997537, 0.5794684678643381, -0.6740059517812944, -0.3239847771997537),
|
731
|
-
new Grad4(-0.4004672082940195, 0.5029860367700724, -0.7504883828755602, 0.15296486218853164),
|
732
|
-
new Grad4( 0.15296486218853164, 0.5029860367700724, -0.7504883828755602, -0.4004672082940195),
|
733
|
-
new Grad4( 0.08164729285680945, 0.4553054119602712, -0.8828161875373585, 0.08164729285680945),
|
734
|
-
new Grad4(-0.08164729285680945, 0.8828161875373585, -0.4553054119602712, -0.08164729285680945),
|
735
|
-
new Grad4(-0.15296486218853164, 0.7504883828755602, -0.5029860367700724, 0.4004672082940195),
|
736
|
-
new Grad4( 0.4004672082940195, 0.7504883828755602, -0.5029860367700724, -0.15296486218853164),
|
737
|
-
new Grad4( 0.3239847771997537, 0.6740059517812944, -0.5794684678643381, 0.3239847771997537),
|
738
|
-
new Grad4(-0.3239847771997537, 0.5794684678643381, -0.3239847771997537, -0.6740059517812944),
|
739
|
-
new Grad4(-0.4004672082940195, 0.5029860367700724, 0.15296486218853164, -0.7504883828755602),
|
740
|
-
new Grad4( 0.15296486218853164, 0.5029860367700724, -0.4004672082940195, -0.7504883828755602),
|
741
|
-
new Grad4( 0.08164729285680945, 0.4553054119602712, 0.08164729285680945, -0.8828161875373585),
|
742
|
-
new Grad4(-0.08164729285680945, 0.8828161875373585, -0.08164729285680945, -0.4553054119602712),
|
743
|
-
new Grad4(-0.15296486218853164, 0.7504883828755602, 0.4004672082940195, -0.5029860367700724),
|
744
|
-
new Grad4( 0.4004672082940195, 0.7504883828755602, -0.15296486218853164, -0.5029860367700724),
|
745
|
-
new Grad4( 0.3239847771997537, 0.6740059517812944, 0.3239847771997537, -0.5794684678643381),
|
746
|
-
new Grad4( 0.5794684678643381, -0.6740059517812944, -0.3239847771997537, -0.3239847771997537),
|
747
|
-
new Grad4( 0.5029860367700724, -0.7504883828755602, -0.4004672082940195, 0.15296486218853164),
|
748
|
-
new Grad4( 0.5029860367700724, -0.7504883828755602, 0.15296486218853164, -0.4004672082940195),
|
749
|
-
new Grad4( 0.4553054119602712, -0.8828161875373585, 0.08164729285680945, 0.08164729285680945),
|
750
|
-
new Grad4( 0.8828161875373585, -0.4553054119602712, -0.08164729285680945, -0.08164729285680945),
|
751
|
-
new Grad4( 0.7504883828755602, -0.5029860367700724, -0.15296486218853164, 0.4004672082940195),
|
752
|
-
new Grad4( 0.7504883828755602, -0.5029860367700724, 0.4004672082940195, -0.15296486218853164),
|
753
|
-
new Grad4( 0.6740059517812944, -0.5794684678643381, 0.3239847771997537, 0.3239847771997537),
|
754
|
-
new Grad4( 0.5794684678643381, -0.3239847771997537, -0.6740059517812944, -0.3239847771997537),
|
755
|
-
new Grad4( 0.5029860367700724, -0.4004672082940195, -0.7504883828755602, 0.15296486218853164),
|
756
|
-
new Grad4( 0.5029860367700724, 0.15296486218853164, -0.7504883828755602, -0.4004672082940195),
|
757
|
-
new Grad4( 0.4553054119602712, 0.08164729285680945, -0.8828161875373585, 0.08164729285680945),
|
758
|
-
new Grad4( 0.8828161875373585, -0.08164729285680945, -0.4553054119602712, -0.08164729285680945),
|
759
|
-
new Grad4( 0.7504883828755602, -0.15296486218853164, -0.5029860367700724, 0.4004672082940195),
|
760
|
-
new Grad4( 0.7504883828755602, 0.4004672082940195, -0.5029860367700724, -0.15296486218853164),
|
761
|
-
new Grad4( 0.6740059517812944, 0.3239847771997537, -0.5794684678643381, 0.3239847771997537),
|
762
|
-
new Grad4( 0.5794684678643381, -0.3239847771997537, -0.3239847771997537, -0.6740059517812944),
|
763
|
-
new Grad4( 0.5029860367700724, -0.4004672082940195, 0.15296486218853164, -0.7504883828755602),
|
764
|
-
new Grad4( 0.5029860367700724, 0.15296486218853164, -0.4004672082940195, -0.7504883828755602),
|
765
|
-
new Grad4( 0.4553054119602712, 0.08164729285680945, 0.08164729285680945, -0.8828161875373585),
|
766
|
-
new Grad4( 0.8828161875373585, -0.08164729285680945, -0.08164729285680945, -0.4553054119602712),
|
767
|
-
new Grad4( 0.7504883828755602, -0.15296486218853164, 0.4004672082940195, -0.5029860367700724),
|
768
|
-
new Grad4( 0.7504883828755602, 0.4004672082940195, -0.15296486218853164, -0.5029860367700724),
|
769
|
-
new Grad4( 0.6740059517812944, 0.3239847771997537, 0.3239847771997537, -0.5794684678643381),
|
770
|
-
new Grad4( 0.03381941603233842, 0.03381941603233842, 0.03381941603233842, 0.9982828964265062),
|
771
|
-
new Grad4(-0.044802370851755174, -0.044802370851755174, 0.508629699630796, 0.8586508742123365),
|
772
|
-
new Grad4(-0.044802370851755174, 0.508629699630796, -0.044802370851755174, 0.8586508742123365),
|
773
|
-
new Grad4(-0.12128480194602098, 0.4321472685365301, 0.4321472685365301, 0.7821684431180708),
|
774
|
-
new Grad4( 0.508629699630796, -0.044802370851755174, -0.044802370851755174, 0.8586508742123365),
|
775
|
-
new Grad4( 0.4321472685365301, -0.12128480194602098, 0.4321472685365301, 0.7821684431180708),
|
776
|
-
new Grad4( 0.4321472685365301, 0.4321472685365301, -0.12128480194602098, 0.7821684431180708),
|
777
|
-
new Grad4( 0.37968289875261624, 0.37968289875261624, 0.37968289875261624, 0.753341017856078),
|
778
|
-
new Grad4( 0.03381941603233842, 0.03381941603233842, 0.9982828964265062, 0.03381941603233842),
|
779
|
-
new Grad4(-0.044802370851755174, 0.044802370851755174, 0.8586508742123365, 0.508629699630796),
|
780
|
-
new Grad4(-0.044802370851755174, 0.508629699630796, 0.8586508742123365, -0.044802370851755174),
|
781
|
-
new Grad4(-0.12128480194602098, 0.4321472685365301, 0.7821684431180708, 0.4321472685365301),
|
782
|
-
new Grad4( 0.508629699630796, -0.044802370851755174, 0.8586508742123365, -0.044802370851755174),
|
783
|
-
new Grad4( 0.4321472685365301, -0.12128480194602098, 0.7821684431180708, 0.4321472685365301),
|
784
|
-
new Grad4( 0.4321472685365301, 0.4321472685365301, 0.7821684431180708, -0.12128480194602098),
|
785
|
-
new Grad4( 0.37968289875261624, 0.37968289875261624, 0.753341017856078, 0.37968289875261624),
|
786
|
-
new Grad4( 0.03381941603233842, 0.9982828964265062, 0.03381941603233842, 0.03381941603233842),
|
787
|
-
new Grad4(-0.044802370851755174, 0.8586508742123365, -0.044802370851755174, 0.508629699630796),
|
788
|
-
new Grad4(-0.044802370851755174, 0.8586508742123365, 0.508629699630796, -0.044802370851755174),
|
789
|
-
new Grad4(-0.12128480194602098, 0.7821684431180708, 0.4321472685365301, 0.4321472685365301),
|
790
|
-
new Grad4( 0.508629699630796, 0.8586508742123365, -0.044802370851755174, -0.044802370851755174),
|
791
|
-
new Grad4( 0.4321472685365301, 0.7821684431180708, -0.12128480194602098, 0.4321472685365301),
|
792
|
-
new Grad4( 0.4321472685365301, 0.7821684431180708, 0.4321472685365301, -0.12128480194602098),
|
793
|
-
new Grad4( 0.37968289875261624, 0.753341017856078, 0.37968289875261624, 0.37968289875261624),
|
794
|
-
new Grad4( 0.9982828964265062, 0.03381941603233842, 0.03381941603233842, 0.03381941603233842),
|
795
|
-
new Grad4( 0.8586508742123365, -0.044802370851755174, -0.044802370851755174, 0.508629699630796),
|
796
|
-
new Grad4( 0.8586508742123365, -0.044802370851755174, 0.508629699630796, -0.044802370851755174),
|
797
|
-
new Grad4( 0.7821684431180708, -0.12128480194602098, 0.4321472685365301, 0.4321472685365301),
|
798
|
-
new Grad4( 0.8586508742123365, 0.508629699630796, -0.044802370851755174, -0.044802370851755174),
|
799
|
-
new Grad4( 0.7821684431180708, 0.4321472685365301, -0.12128480194602098, 0.4321472685365301),
|
800
|
-
new Grad4( 0.7821684431180708, 0.4321472685365301, 0.4321472685365301, -0.12128480194602098),
|
801
|
-
new Grad4( 0.753341017856078, 0.37968289875261624, 0.37968289875261624, 0.37968289875261624)
|
802
|
-
};
|
803
|
-
for (Grad4 grad41 : grad4) {
|
804
|
-
grad41.dx /= N4;
|
805
|
-
grad41.dy /= N4;
|
806
|
-
grad41.dz /= N4;
|
807
|
-
grad41.dw /= N4;
|
396
|
+
}
|
397
|
+
if (bsi > asi) {
|
398
|
+
via = vib;
|
399
|
+
double temp = bsi;
|
400
|
+
bsi = asi;
|
401
|
+
asi = temp;
|
402
|
+
}
|
403
|
+
if (siSum + asi > 3) {
|
404
|
+
vertexIndex = via;
|
405
|
+
if (siSum + bsi > 4) {
|
406
|
+
vertexIndex = 0b1111;
|
407
|
+
}
|
408
|
+
}
|
409
|
+
|
410
|
+
// Now flip back if we're actually in the lower half.
|
411
|
+
if (inLowerHalf) {
|
412
|
+
xsi = 1 - xsi;
|
413
|
+
ysi = 1 - ysi;
|
414
|
+
zsi = 1 - zsi;
|
415
|
+
wsi = 1 - wsi;
|
416
|
+
vertexIndex ^= 0b1111;
|
417
|
+
}
|
418
|
+
|
419
|
+
// Five points to add, total, from five copies of the A4 lattice.
|
420
|
+
for (int i = 0; i < 5; i++) {
|
421
|
+
|
422
|
+
// Update xsb/etc. and add the lattice point's contribution.
|
423
|
+
LatticePoint4D c = VERTICES_4D[vertexIndex];
|
424
|
+
xsb += c.xsv;
|
425
|
+
ysb += c.ysv;
|
426
|
+
zsb += c.zsv;
|
427
|
+
wsb += c.wsv;
|
428
|
+
double xi = xsi + ssi, yi = ysi + ssi, zi = zsi + ssi, wi = wsi + ssi;
|
429
|
+
double dx = xi + c.dx, dy = yi + c.dy, dz = zi + c.dz, dw = wi + c.dw;
|
430
|
+
double attn = 0.5 - dx * dx - dy * dy - dz * dz - dw * dw;
|
431
|
+
if (attn > 0) {
|
432
|
+
int pxm = xsb & PMASK, pym = ysb & PMASK, pzm = zsb & PMASK, pwm = wsb & PMASK;
|
433
|
+
Grad4 grad = permGrad4[perm[perm[perm[pxm] ^ pym] ^ pzm] ^ pwm];
|
434
|
+
double ramped = grad.dx * dx + grad.dy * dy + grad.dz * dz + grad.dw * dw;
|
435
|
+
|
436
|
+
attn *= attn;
|
437
|
+
value += attn * attn * ramped;
|
438
|
+
}
|
439
|
+
|
440
|
+
// Maybe this helps the compiler/JVM/LLVM/etc. know we can end the loop here. Maybe not.
|
441
|
+
if (i == 4) {
|
442
|
+
break;
|
443
|
+
}
|
444
|
+
|
445
|
+
// Update the relative skewed coordinates to reference the vertex we just added.
|
446
|
+
// Rather, reference its counterpart on the lattice copy that is shifted down by
|
447
|
+
// the vector <-0.2, -0.2, -0.2, -0.2>
|
448
|
+
xsi += c.xsi;
|
449
|
+
ysi += c.ysi;
|
450
|
+
zsi += c.zsi;
|
451
|
+
wsi += c.wsi;
|
452
|
+
ssi += c.ssiDelta;
|
453
|
+
|
454
|
+
// Next point is the closest vertex on the 4-simplex whose base vertex is the aforementioned vertex.
|
455
|
+
double score0 = 1.0 + ssi * (-1.0 / 0.309016994374947); // Seems slightly faster than 1.0-xsi-ysi-zsi-wsi
|
456
|
+
vertexIndex = 0b0000;
|
457
|
+
if (xsi >= ysi && xsi >= zsi && xsi >= wsi && xsi >= score0) {
|
458
|
+
vertexIndex = 0b0001;
|
459
|
+
} else if (ysi > xsi && ysi >= zsi && ysi >= wsi && ysi >= score0) {
|
460
|
+
vertexIndex = 0b0010;
|
461
|
+
} else if (zsi > xsi && zsi > ysi && zsi >= wsi && zsi >= score0) {
|
462
|
+
vertexIndex = 0b0100;
|
463
|
+
} else if (wsi > xsi && wsi > ysi && wsi > zsi && wsi >= score0) {
|
464
|
+
vertexIndex = 0b1000;
|
808
465
|
}
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
466
|
+
}
|
467
|
+
|
468
|
+
return value;
|
469
|
+
}
|
470
|
+
|
471
|
+
/*
|
472
|
+
* Utility
|
473
|
+
*/
|
474
|
+
private static int fastFloor(double x) {
|
475
|
+
int xi = (int) x;
|
476
|
+
return x < xi ? xi - 1 : xi;
|
477
|
+
}
|
478
|
+
|
479
|
+
/*
|
480
|
+
* Definitions
|
481
|
+
*/
|
482
|
+
private static final LatticePoint2D[] LOOKUP_2D;
|
483
|
+
private static final LatticePoint3D[] LOOKUP_3D;
|
484
|
+
private static final LatticePoint4D[] VERTICES_4D;
|
485
|
+
|
486
|
+
static {
|
487
|
+
LOOKUP_2D = new LatticePoint2D[4];
|
488
|
+
LOOKUP_3D = new LatticePoint3D[8];
|
489
|
+
VERTICES_4D = new LatticePoint4D[16];
|
490
|
+
|
491
|
+
LOOKUP_2D[0] = new LatticePoint2D(1, 0);
|
492
|
+
LOOKUP_2D[1] = new LatticePoint2D(0, 0);
|
493
|
+
LOOKUP_2D[2] = new LatticePoint2D(1, 1);
|
494
|
+
LOOKUP_2D[3] = new LatticePoint2D(0, 1);
|
495
|
+
|
496
|
+
for (int i = 0; i < 8; i++) {
|
497
|
+
int i1, j1, k1, i2, j2, k2;
|
498
|
+
i1 = (i) & 1;
|
499
|
+
j1 = (i >> 1) & 1;
|
500
|
+
k1 = (i >> 2) & 1;
|
501
|
+
i2 = i1 ^ 1;
|
502
|
+
j2 = j1 ^ 1;
|
503
|
+
k2 = k1 ^ 1;
|
504
|
+
|
505
|
+
// The two points within this octant, one from each of the two cubic half-lattices.
|
506
|
+
LatticePoint3D c0 = new LatticePoint3D(i1, j1, k1, 0);
|
507
|
+
LatticePoint3D c1 = new LatticePoint3D(i1 + i2, j1 + j2, k1 + k2, 1);
|
508
|
+
|
509
|
+
// Each single step away on the first half-lattice.
|
510
|
+
LatticePoint3D c2 = new LatticePoint3D(i1 ^ 1, j1, k1, 0);
|
511
|
+
LatticePoint3D c3 = new LatticePoint3D(i1, j1 ^ 1, k1, 0);
|
512
|
+
LatticePoint3D c4 = new LatticePoint3D(i1, j1, k1 ^ 1, 0);
|
513
|
+
|
514
|
+
// Each single step away on the second half-lattice.
|
515
|
+
LatticePoint3D c5 = new LatticePoint3D(i1 + (i2 ^ 1), j1 + j2, k1 + k2, 1);
|
516
|
+
LatticePoint3D c6 = new LatticePoint3D(i1 + i2, j1 + (j2 ^ 1), k1 + k2, 1);
|
517
|
+
LatticePoint3D c7 = new LatticePoint3D(i1 + i2, j1 + j2, k1 + (k2 ^ 1), 1);
|
518
|
+
|
519
|
+
// First two are guaranteed.
|
520
|
+
c0.nextOnFailure = c0.nextOnSuccess = c1;
|
521
|
+
c1.nextOnFailure = c1.nextOnSuccess = c2;
|
522
|
+
|
523
|
+
// Once we find one on the first half-lattice, the rest are out.
|
524
|
+
// In addition, knowing c2 rules out c5.
|
525
|
+
c2.nextOnFailure = c3;
|
526
|
+
c2.nextOnSuccess = c6;
|
527
|
+
c3.nextOnFailure = c4;
|
528
|
+
c3.nextOnSuccess = c5;
|
529
|
+
c4.nextOnFailure = c4.nextOnSuccess = c5;
|
530
|
+
|
531
|
+
// Once we find one on the second half-lattice, the rest are out.
|
532
|
+
c5.nextOnFailure = c6;
|
533
|
+
c5.nextOnSuccess = null;
|
534
|
+
c6.nextOnFailure = c7;
|
535
|
+
c6.nextOnSuccess = null;
|
536
|
+
c7.nextOnFailure = c7.nextOnSuccess = null;
|
537
|
+
|
538
|
+
LOOKUP_3D[i] = c0;
|
539
|
+
}
|
540
|
+
|
541
|
+
for (int i = 0; i < 16; i++) {
|
542
|
+
VERTICES_4D[i] = new LatticePoint4D((i) & 1, (i >> 1) & 1, (i >> 2) & 1, (i >> 3) & 1);
|
543
|
+
}
|
544
|
+
}
|
545
|
+
|
546
|
+
private static class LatticePoint2D {
|
547
|
+
|
548
|
+
int xsv, ysv;
|
549
|
+
double dx, dy;
|
550
|
+
|
551
|
+
public LatticePoint2D(int xsv, int ysv) {
|
552
|
+
this.xsv = xsv;
|
553
|
+
this.ysv = ysv;
|
554
|
+
double ssv = (xsv + ysv) * -0.211324865405187;
|
555
|
+
this.dx = -xsv - ssv;
|
556
|
+
this.dy = -ysv - ssv;
|
557
|
+
}
|
558
|
+
}
|
559
|
+
|
560
|
+
private static class LatticePoint3D {
|
561
|
+
|
562
|
+
public double dxr, dyr, dzr;
|
563
|
+
public int xrv, yrv, zrv;
|
564
|
+
LatticePoint3D nextOnFailure, nextOnSuccess;
|
565
|
+
|
566
|
+
public LatticePoint3D(int xrv, int yrv, int zrv, int lattice) {
|
567
|
+
this.dxr = -xrv + lattice * 0.5;
|
568
|
+
this.dyr = -yrv + lattice * 0.5;
|
569
|
+
this.dzr = -zrv + lattice * 0.5;
|
570
|
+
this.xrv = xrv + lattice * 1024;
|
571
|
+
this.yrv = yrv + lattice * 1024;
|
572
|
+
this.zrv = zrv + lattice * 1024;
|
573
|
+
}
|
574
|
+
}
|
575
|
+
|
576
|
+
private static class LatticePoint4D {
|
577
|
+
|
578
|
+
int xsv, ysv, zsv, wsv;
|
579
|
+
double dx, dy, dz, dw;
|
580
|
+
double xsi, ysi, zsi, wsi;
|
581
|
+
double ssiDelta;
|
582
|
+
|
583
|
+
public LatticePoint4D(int xsv, int ysv, int zsv, int wsv) {
|
584
|
+
this.xsv = xsv + 409;
|
585
|
+
this.ysv = ysv + 409;
|
586
|
+
this.zsv = zsv + 409;
|
587
|
+
this.wsv = wsv + 409;
|
588
|
+
double ssv = (xsv + ysv + zsv + wsv) * 0.309016994374947;
|
589
|
+
this.dx = -xsv - ssv;
|
590
|
+
this.dy = -ysv - ssv;
|
591
|
+
this.dz = -zsv - ssv;
|
592
|
+
this.dw = -wsv - ssv;
|
593
|
+
this.xsi = 0.2 - xsv;
|
594
|
+
this.ysi = 0.2 - ysv;
|
595
|
+
this.zsi = 0.2 - zsv;
|
596
|
+
this.wsi = 0.2 - wsv;
|
597
|
+
this.ssiDelta = (0.8 - xsv - ysv - zsv - wsv) * 0.309016994374947;
|
598
|
+
}
|
599
|
+
}
|
600
|
+
|
601
|
+
/*
|
602
|
+
* Gradients
|
603
|
+
*/
|
604
|
+
private static class Grad2 {
|
605
|
+
|
606
|
+
double dx, dy;
|
607
|
+
|
608
|
+
public Grad2(double dx, double dy) {
|
609
|
+
this.dx = dx;
|
610
|
+
this.dy = dy;
|
611
|
+
}
|
612
|
+
}
|
613
|
+
|
614
|
+
private static class Grad3 {
|
615
|
+
|
616
|
+
double dx, dy, dz;
|
617
|
+
|
618
|
+
public Grad3(double dx, double dy, double dz) {
|
619
|
+
this.dx = dx;
|
620
|
+
this.dy = dy;
|
621
|
+
this.dz = dz;
|
622
|
+
}
|
623
|
+
}
|
624
|
+
|
625
|
+
private static class Grad4 {
|
626
|
+
|
627
|
+
double dx, dy, dz, dw;
|
628
|
+
|
629
|
+
public Grad4(double dx, double dy, double dz, double dw) {
|
630
|
+
this.dx = dx;
|
631
|
+
this.dy = dy;
|
632
|
+
this.dz = dz;
|
633
|
+
this.dw = dw;
|
634
|
+
}
|
635
|
+
}
|
636
|
+
|
637
|
+
private static final double N2 = 0.01001634121365712;
|
638
|
+
private static final double N3 = 0.030485933181293584;
|
639
|
+
private static final double N4 = 0.009202377986303158;
|
640
|
+
private static final Grad2[] GRADIENTS_2D;
|
641
|
+
private static final Grad3[] GRADIENTS_3D;
|
642
|
+
private static final Grad4[] GRADIENTS_4D;
|
643
|
+
|
644
|
+
static {
|
645
|
+
|
646
|
+
GRADIENTS_2D = new Grad2[PSIZE];
|
647
|
+
Grad2[] grad2 = {
|
648
|
+
new Grad2(0.130526192220052, 0.99144486137381),
|
649
|
+
new Grad2(0.38268343236509, 0.923879532511287),
|
650
|
+
new Grad2(0.608761429008721, 0.793353340291235),
|
651
|
+
new Grad2(0.793353340291235, 0.608761429008721),
|
652
|
+
new Grad2(0.923879532511287, 0.38268343236509),
|
653
|
+
new Grad2(0.99144486137381, 0.130526192220051),
|
654
|
+
new Grad2(0.99144486137381, -0.130526192220051),
|
655
|
+
new Grad2(0.923879532511287, -0.38268343236509),
|
656
|
+
new Grad2(0.793353340291235, -0.60876142900872),
|
657
|
+
new Grad2(0.608761429008721, -0.793353340291235),
|
658
|
+
new Grad2(0.38268343236509, -0.923879532511287),
|
659
|
+
new Grad2(0.130526192220052, -0.99144486137381),
|
660
|
+
new Grad2(-0.130526192220052, -0.99144486137381),
|
661
|
+
new Grad2(-0.38268343236509, -0.923879532511287),
|
662
|
+
new Grad2(-0.608761429008721, -0.793353340291235),
|
663
|
+
new Grad2(-0.793353340291235, -0.608761429008721),
|
664
|
+
new Grad2(-0.923879532511287, -0.38268343236509),
|
665
|
+
new Grad2(-0.99144486137381, -0.130526192220052),
|
666
|
+
new Grad2(-0.99144486137381, 0.130526192220051),
|
667
|
+
new Grad2(-0.923879532511287, 0.38268343236509),
|
668
|
+
new Grad2(-0.793353340291235, 0.608761429008721),
|
669
|
+
new Grad2(-0.608761429008721, 0.793353340291235),
|
670
|
+
new Grad2(-0.38268343236509, 0.923879532511287),
|
671
|
+
new Grad2(-0.130526192220052, 0.99144486137381)
|
672
|
+
};
|
673
|
+
for (Grad2 grad21 : grad2) {
|
674
|
+
grad21.dx /= N2;
|
675
|
+
grad21.dy /= N2;
|
676
|
+
}
|
677
|
+
for (int i = 0; i < PSIZE; i++) {
|
678
|
+
GRADIENTS_2D[i] = grad2[i % grad2.length];
|
679
|
+
}
|
680
|
+
|
681
|
+
GRADIENTS_3D = new Grad3[PSIZE];
|
682
|
+
Grad3[] grad3 = {
|
683
|
+
new Grad3(-2.22474487139, -2.22474487139, -1.0),
|
684
|
+
new Grad3(-2.22474487139, -2.22474487139, 1.0),
|
685
|
+
new Grad3(-3.0862664687972017, -1.1721513422464978, 0.0),
|
686
|
+
new Grad3(-1.1721513422464978, -3.0862664687972017, 0.0),
|
687
|
+
new Grad3(-2.22474487139, -1.0, -2.22474487139),
|
688
|
+
new Grad3(-2.22474487139, 1.0, -2.22474487139),
|
689
|
+
new Grad3(-1.1721513422464978, 0.0, -3.0862664687972017),
|
690
|
+
new Grad3(-3.0862664687972017, 0.0, -1.1721513422464978),
|
691
|
+
new Grad3(-2.22474487139, -1.0, 2.22474487139),
|
692
|
+
new Grad3(-2.22474487139, 1.0, 2.22474487139),
|
693
|
+
new Grad3(-3.0862664687972017, 0.0, 1.1721513422464978),
|
694
|
+
new Grad3(-1.1721513422464978, 0.0, 3.0862664687972017),
|
695
|
+
new Grad3(-2.22474487139, 2.22474487139, -1.0),
|
696
|
+
new Grad3(-2.22474487139, 2.22474487139, 1.0),
|
697
|
+
new Grad3(-1.1721513422464978, 3.0862664687972017, 0.0),
|
698
|
+
new Grad3(-3.0862664687972017, 1.1721513422464978, 0.0),
|
699
|
+
new Grad3(-1.0, -2.22474487139, -2.22474487139),
|
700
|
+
new Grad3(1.0, -2.22474487139, -2.22474487139),
|
701
|
+
new Grad3(0.0, -3.0862664687972017, -1.1721513422464978),
|
702
|
+
new Grad3(0.0, -1.1721513422464978, -3.0862664687972017),
|
703
|
+
new Grad3(-1.0, -2.22474487139, 2.22474487139),
|
704
|
+
new Grad3(1.0, -2.22474487139, 2.22474487139),
|
705
|
+
new Grad3(0.0, -1.1721513422464978, 3.0862664687972017),
|
706
|
+
new Grad3(0.0, -3.0862664687972017, 1.1721513422464978),
|
707
|
+
new Grad3(-1.0, 2.22474487139, -2.22474487139),
|
708
|
+
new Grad3(1.0, 2.22474487139, -2.22474487139),
|
709
|
+
new Grad3(0.0, 1.1721513422464978, -3.0862664687972017),
|
710
|
+
new Grad3(0.0, 3.0862664687972017, -1.1721513422464978),
|
711
|
+
new Grad3(-1.0, 2.22474487139, 2.22474487139),
|
712
|
+
new Grad3(1.0, 2.22474487139, 2.22474487139),
|
713
|
+
new Grad3(0.0, 3.0862664687972017, 1.1721513422464978),
|
714
|
+
new Grad3(0.0, 1.1721513422464978, 3.0862664687972017),
|
715
|
+
new Grad3(2.22474487139, -2.22474487139, -1.0),
|
716
|
+
new Grad3(2.22474487139, -2.22474487139, 1.0),
|
717
|
+
new Grad3(1.1721513422464978, -3.0862664687972017, 0.0),
|
718
|
+
new Grad3(3.0862664687972017, -1.1721513422464978, 0.0),
|
719
|
+
new Grad3(2.22474487139, -1.0, -2.22474487139),
|
720
|
+
new Grad3(2.22474487139, 1.0, -2.22474487139),
|
721
|
+
new Grad3(3.0862664687972017, 0.0, -1.1721513422464978),
|
722
|
+
new Grad3(1.1721513422464978, 0.0, -3.0862664687972017),
|
723
|
+
new Grad3(2.22474487139, -1.0, 2.22474487139),
|
724
|
+
new Grad3(2.22474487139, 1.0, 2.22474487139),
|
725
|
+
new Grad3(1.1721513422464978, 0.0, 3.0862664687972017),
|
726
|
+
new Grad3(3.0862664687972017, 0.0, 1.1721513422464978),
|
727
|
+
new Grad3(2.22474487139, 2.22474487139, -1.0),
|
728
|
+
new Grad3(2.22474487139, 2.22474487139, 1.0),
|
729
|
+
new Grad3(3.0862664687972017, 1.1721513422464978, 0.0),
|
730
|
+
new Grad3(1.1721513422464978, 3.0862664687972017, 0.0)
|
731
|
+
};
|
732
|
+
for (Grad3 grad31 : grad3) {
|
733
|
+
grad31.dx /= N3;
|
734
|
+
grad31.dy /= N3;
|
735
|
+
grad31.dz /= N3;
|
736
|
+
}
|
737
|
+
for (int i = 0; i < PSIZE; i++) {
|
738
|
+
GRADIENTS_3D[i] = grad3[i % grad3.length];
|
739
|
+
}
|
740
|
+
|
741
|
+
GRADIENTS_4D = new Grad4[PSIZE];
|
742
|
+
Grad4[] grad4 = {
|
743
|
+
new Grad4(-0.753341017856078, -0.37968289875261624, -0.37968289875261624, -0.37968289875261624),
|
744
|
+
new Grad4(-0.7821684431180708, -0.4321472685365301, -0.4321472685365301, 0.12128480194602098),
|
745
|
+
new Grad4(-0.7821684431180708, -0.4321472685365301, 0.12128480194602098, -0.4321472685365301),
|
746
|
+
new Grad4(-0.7821684431180708, 0.12128480194602098, -0.4321472685365301, -0.4321472685365301),
|
747
|
+
new Grad4(-0.8586508742123365, -0.508629699630796, 0.044802370851755174, 0.044802370851755174),
|
748
|
+
new Grad4(-0.8586508742123365, 0.044802370851755174, -0.508629699630796, 0.044802370851755174),
|
749
|
+
new Grad4(-0.8586508742123365, 0.044802370851755174, 0.044802370851755174, -0.508629699630796),
|
750
|
+
new Grad4(-0.9982828964265062, -0.03381941603233842, -0.03381941603233842, -0.03381941603233842),
|
751
|
+
new Grad4(-0.37968289875261624, -0.753341017856078, -0.37968289875261624, -0.37968289875261624),
|
752
|
+
new Grad4(-0.4321472685365301, -0.7821684431180708, -0.4321472685365301, 0.12128480194602098),
|
753
|
+
new Grad4(-0.4321472685365301, -0.7821684431180708, 0.12128480194602098, -0.4321472685365301),
|
754
|
+
new Grad4(0.12128480194602098, -0.7821684431180708, -0.4321472685365301, -0.4321472685365301),
|
755
|
+
new Grad4(-0.508629699630796, -0.8586508742123365, 0.044802370851755174, 0.044802370851755174),
|
756
|
+
new Grad4(0.044802370851755174, -0.8586508742123365, -0.508629699630796, 0.044802370851755174),
|
757
|
+
new Grad4(0.044802370851755174, -0.8586508742123365, 0.044802370851755174, -0.508629699630796),
|
758
|
+
new Grad4(-0.03381941603233842, -0.9982828964265062, -0.03381941603233842, -0.03381941603233842),
|
759
|
+
new Grad4(-0.37968289875261624, -0.37968289875261624, -0.753341017856078, -0.37968289875261624),
|
760
|
+
new Grad4(-0.4321472685365301, -0.4321472685365301, -0.7821684431180708, 0.12128480194602098),
|
761
|
+
new Grad4(-0.4321472685365301, 0.12128480194602098, -0.7821684431180708, -0.4321472685365301),
|
762
|
+
new Grad4(0.12128480194602098, -0.4321472685365301, -0.7821684431180708, -0.4321472685365301),
|
763
|
+
new Grad4(-0.508629699630796, 0.044802370851755174, -0.8586508742123365, 0.044802370851755174),
|
764
|
+
new Grad4(0.044802370851755174, -0.508629699630796, -0.8586508742123365, 0.044802370851755174),
|
765
|
+
new Grad4(0.044802370851755174, 0.044802370851755174, -0.8586508742123365, -0.508629699630796),
|
766
|
+
new Grad4(-0.03381941603233842, -0.03381941603233842, -0.9982828964265062, -0.03381941603233842),
|
767
|
+
new Grad4(-0.37968289875261624, -0.37968289875261624, -0.37968289875261624, -0.753341017856078),
|
768
|
+
new Grad4(-0.4321472685365301, -0.4321472685365301, 0.12128480194602098, -0.7821684431180708),
|
769
|
+
new Grad4(-0.4321472685365301, 0.12128480194602098, -0.4321472685365301, -0.7821684431180708),
|
770
|
+
new Grad4(0.12128480194602098, -0.4321472685365301, -0.4321472685365301, -0.7821684431180708),
|
771
|
+
new Grad4(-0.508629699630796, 0.044802370851755174, 0.044802370851755174, -0.8586508742123365),
|
772
|
+
new Grad4(0.044802370851755174, -0.508629699630796, 0.044802370851755174, -0.8586508742123365),
|
773
|
+
new Grad4(0.044802370851755174, 0.044802370851755174, -0.508629699630796, -0.8586508742123365),
|
774
|
+
new Grad4(-0.03381941603233842, -0.03381941603233842, -0.03381941603233842, -0.9982828964265062),
|
775
|
+
new Grad4(-0.6740059517812944, -0.3239847771997537, -0.3239847771997537, 0.5794684678643381),
|
776
|
+
new Grad4(-0.7504883828755602, -0.4004672082940195, 0.15296486218853164, 0.5029860367700724),
|
777
|
+
new Grad4(-0.7504883828755602, 0.15296486218853164, -0.4004672082940195, 0.5029860367700724),
|
778
|
+
new Grad4(-0.8828161875373585, 0.08164729285680945, 0.08164729285680945, 0.4553054119602712),
|
779
|
+
new Grad4(-0.4553054119602712, -0.08164729285680945, -0.08164729285680945, 0.8828161875373585),
|
780
|
+
new Grad4(-0.5029860367700724, -0.15296486218853164, 0.4004672082940195, 0.7504883828755602),
|
781
|
+
new Grad4(-0.5029860367700724, 0.4004672082940195, -0.15296486218853164, 0.7504883828755602),
|
782
|
+
new Grad4(-0.5794684678643381, 0.3239847771997537, 0.3239847771997537, 0.6740059517812944),
|
783
|
+
new Grad4(-0.3239847771997537, -0.6740059517812944, -0.3239847771997537, 0.5794684678643381),
|
784
|
+
new Grad4(-0.4004672082940195, -0.7504883828755602, 0.15296486218853164, 0.5029860367700724),
|
785
|
+
new Grad4(0.15296486218853164, -0.7504883828755602, -0.4004672082940195, 0.5029860367700724),
|
786
|
+
new Grad4(0.08164729285680945, -0.8828161875373585, 0.08164729285680945, 0.4553054119602712),
|
787
|
+
new Grad4(-0.08164729285680945, -0.4553054119602712, -0.08164729285680945, 0.8828161875373585),
|
788
|
+
new Grad4(-0.15296486218853164, -0.5029860367700724, 0.4004672082940195, 0.7504883828755602),
|
789
|
+
new Grad4(0.4004672082940195, -0.5029860367700724, -0.15296486218853164, 0.7504883828755602),
|
790
|
+
new Grad4(0.3239847771997537, -0.5794684678643381, 0.3239847771997537, 0.6740059517812944),
|
791
|
+
new Grad4(-0.3239847771997537, -0.3239847771997537, -0.6740059517812944, 0.5794684678643381),
|
792
|
+
new Grad4(-0.4004672082940195, 0.15296486218853164, -0.7504883828755602, 0.5029860367700724),
|
793
|
+
new Grad4(0.15296486218853164, -0.4004672082940195, -0.7504883828755602, 0.5029860367700724),
|
794
|
+
new Grad4(0.08164729285680945, 0.08164729285680945, -0.8828161875373585, 0.4553054119602712),
|
795
|
+
new Grad4(-0.08164729285680945, -0.08164729285680945, -0.4553054119602712, 0.8828161875373585),
|
796
|
+
new Grad4(-0.15296486218853164, 0.4004672082940195, -0.5029860367700724, 0.7504883828755602),
|
797
|
+
new Grad4(0.4004672082940195, -0.15296486218853164, -0.5029860367700724, 0.7504883828755602),
|
798
|
+
new Grad4(0.3239847771997537, 0.3239847771997537, -0.5794684678643381, 0.6740059517812944),
|
799
|
+
new Grad4(-0.6740059517812944, -0.3239847771997537, 0.5794684678643381, -0.3239847771997537),
|
800
|
+
new Grad4(-0.7504883828755602, -0.4004672082940195, 0.5029860367700724, 0.15296486218853164),
|
801
|
+
new Grad4(-0.7504883828755602, 0.15296486218853164, 0.5029860367700724, -0.4004672082940195),
|
802
|
+
new Grad4(-0.8828161875373585, 0.08164729285680945, 0.4553054119602712, 0.08164729285680945),
|
803
|
+
new Grad4(-0.4553054119602712, -0.08164729285680945, 0.8828161875373585, -0.08164729285680945),
|
804
|
+
new Grad4(-0.5029860367700724, -0.15296486218853164, 0.7504883828755602, 0.4004672082940195),
|
805
|
+
new Grad4(-0.5029860367700724, 0.4004672082940195, 0.7504883828755602, -0.15296486218853164),
|
806
|
+
new Grad4(-0.5794684678643381, 0.3239847771997537, 0.6740059517812944, 0.3239847771997537),
|
807
|
+
new Grad4(-0.3239847771997537, -0.6740059517812944, 0.5794684678643381, -0.3239847771997537),
|
808
|
+
new Grad4(-0.4004672082940195, -0.7504883828755602, 0.5029860367700724, 0.15296486218853164),
|
809
|
+
new Grad4(0.15296486218853164, -0.7504883828755602, 0.5029860367700724, -0.4004672082940195),
|
810
|
+
new Grad4(0.08164729285680945, -0.8828161875373585, 0.4553054119602712, 0.08164729285680945),
|
811
|
+
new Grad4(-0.08164729285680945, -0.4553054119602712, 0.8828161875373585, -0.08164729285680945),
|
812
|
+
new Grad4(-0.15296486218853164, -0.5029860367700724, 0.7504883828755602, 0.4004672082940195),
|
813
|
+
new Grad4(0.4004672082940195, -0.5029860367700724, 0.7504883828755602, -0.15296486218853164),
|
814
|
+
new Grad4(0.3239847771997537, -0.5794684678643381, 0.6740059517812944, 0.3239847771997537),
|
815
|
+
new Grad4(-0.3239847771997537, -0.3239847771997537, 0.5794684678643381, -0.6740059517812944),
|
816
|
+
new Grad4(-0.4004672082940195, 0.15296486218853164, 0.5029860367700724, -0.7504883828755602),
|
817
|
+
new Grad4(0.15296486218853164, -0.4004672082940195, 0.5029860367700724, -0.7504883828755602),
|
818
|
+
new Grad4(0.08164729285680945, 0.08164729285680945, 0.4553054119602712, -0.8828161875373585),
|
819
|
+
new Grad4(-0.08164729285680945, -0.08164729285680945, 0.8828161875373585, -0.4553054119602712),
|
820
|
+
new Grad4(-0.15296486218853164, 0.4004672082940195, 0.7504883828755602, -0.5029860367700724),
|
821
|
+
new Grad4(0.4004672082940195, -0.15296486218853164, 0.7504883828755602, -0.5029860367700724),
|
822
|
+
new Grad4(0.3239847771997537, 0.3239847771997537, 0.6740059517812944, -0.5794684678643381),
|
823
|
+
new Grad4(-0.6740059517812944, 0.5794684678643381, -0.3239847771997537, -0.3239847771997537),
|
824
|
+
new Grad4(-0.7504883828755602, 0.5029860367700724, -0.4004672082940195, 0.15296486218853164),
|
825
|
+
new Grad4(-0.7504883828755602, 0.5029860367700724, 0.15296486218853164, -0.4004672082940195),
|
826
|
+
new Grad4(-0.8828161875373585, 0.4553054119602712, 0.08164729285680945, 0.08164729285680945),
|
827
|
+
new Grad4(-0.4553054119602712, 0.8828161875373585, -0.08164729285680945, -0.08164729285680945),
|
828
|
+
new Grad4(-0.5029860367700724, 0.7504883828755602, -0.15296486218853164, 0.4004672082940195),
|
829
|
+
new Grad4(-0.5029860367700724, 0.7504883828755602, 0.4004672082940195, -0.15296486218853164),
|
830
|
+
new Grad4(-0.5794684678643381, 0.6740059517812944, 0.3239847771997537, 0.3239847771997537),
|
831
|
+
new Grad4(-0.3239847771997537, 0.5794684678643381, -0.6740059517812944, -0.3239847771997537),
|
832
|
+
new Grad4(-0.4004672082940195, 0.5029860367700724, -0.7504883828755602, 0.15296486218853164),
|
833
|
+
new Grad4(0.15296486218853164, 0.5029860367700724, -0.7504883828755602, -0.4004672082940195),
|
834
|
+
new Grad4(0.08164729285680945, 0.4553054119602712, -0.8828161875373585, 0.08164729285680945),
|
835
|
+
new Grad4(-0.08164729285680945, 0.8828161875373585, -0.4553054119602712, -0.08164729285680945),
|
836
|
+
new Grad4(-0.15296486218853164, 0.7504883828755602, -0.5029860367700724, 0.4004672082940195),
|
837
|
+
new Grad4(0.4004672082940195, 0.7504883828755602, -0.5029860367700724, -0.15296486218853164),
|
838
|
+
new Grad4(0.3239847771997537, 0.6740059517812944, -0.5794684678643381, 0.3239847771997537),
|
839
|
+
new Grad4(-0.3239847771997537, 0.5794684678643381, -0.3239847771997537, -0.6740059517812944),
|
840
|
+
new Grad4(-0.4004672082940195, 0.5029860367700724, 0.15296486218853164, -0.7504883828755602),
|
841
|
+
new Grad4(0.15296486218853164, 0.5029860367700724, -0.4004672082940195, -0.7504883828755602),
|
842
|
+
new Grad4(0.08164729285680945, 0.4553054119602712, 0.08164729285680945, -0.8828161875373585),
|
843
|
+
new Grad4(-0.08164729285680945, 0.8828161875373585, -0.08164729285680945, -0.4553054119602712),
|
844
|
+
new Grad4(-0.15296486218853164, 0.7504883828755602, 0.4004672082940195, -0.5029860367700724),
|
845
|
+
new Grad4(0.4004672082940195, 0.7504883828755602, -0.15296486218853164, -0.5029860367700724),
|
846
|
+
new Grad4(0.3239847771997537, 0.6740059517812944, 0.3239847771997537, -0.5794684678643381),
|
847
|
+
new Grad4(0.5794684678643381, -0.6740059517812944, -0.3239847771997537, -0.3239847771997537),
|
848
|
+
new Grad4(0.5029860367700724, -0.7504883828755602, -0.4004672082940195, 0.15296486218853164),
|
849
|
+
new Grad4(0.5029860367700724, -0.7504883828755602, 0.15296486218853164, -0.4004672082940195),
|
850
|
+
new Grad4(0.4553054119602712, -0.8828161875373585, 0.08164729285680945, 0.08164729285680945),
|
851
|
+
new Grad4(0.8828161875373585, -0.4553054119602712, -0.08164729285680945, -0.08164729285680945),
|
852
|
+
new Grad4(0.7504883828755602, -0.5029860367700724, -0.15296486218853164, 0.4004672082940195),
|
853
|
+
new Grad4(0.7504883828755602, -0.5029860367700724, 0.4004672082940195, -0.15296486218853164),
|
854
|
+
new Grad4(0.6740059517812944, -0.5794684678643381, 0.3239847771997537, 0.3239847771997537),
|
855
|
+
new Grad4(0.5794684678643381, -0.3239847771997537, -0.6740059517812944, -0.3239847771997537),
|
856
|
+
new Grad4(0.5029860367700724, -0.4004672082940195, -0.7504883828755602, 0.15296486218853164),
|
857
|
+
new Grad4(0.5029860367700724, 0.15296486218853164, -0.7504883828755602, -0.4004672082940195),
|
858
|
+
new Grad4(0.4553054119602712, 0.08164729285680945, -0.8828161875373585, 0.08164729285680945),
|
859
|
+
new Grad4(0.8828161875373585, -0.08164729285680945, -0.4553054119602712, -0.08164729285680945),
|
860
|
+
new Grad4(0.7504883828755602, -0.15296486218853164, -0.5029860367700724, 0.4004672082940195),
|
861
|
+
new Grad4(0.7504883828755602, 0.4004672082940195, -0.5029860367700724, -0.15296486218853164),
|
862
|
+
new Grad4(0.6740059517812944, 0.3239847771997537, -0.5794684678643381, 0.3239847771997537),
|
863
|
+
new Grad4(0.5794684678643381, -0.3239847771997537, -0.3239847771997537, -0.6740059517812944),
|
864
|
+
new Grad4(0.5029860367700724, -0.4004672082940195, 0.15296486218853164, -0.7504883828755602),
|
865
|
+
new Grad4(0.5029860367700724, 0.15296486218853164, -0.4004672082940195, -0.7504883828755602),
|
866
|
+
new Grad4(0.4553054119602712, 0.08164729285680945, 0.08164729285680945, -0.8828161875373585),
|
867
|
+
new Grad4(0.8828161875373585, -0.08164729285680945, -0.08164729285680945, -0.4553054119602712),
|
868
|
+
new Grad4(0.7504883828755602, -0.15296486218853164, 0.4004672082940195, -0.5029860367700724),
|
869
|
+
new Grad4(0.7504883828755602, 0.4004672082940195, -0.15296486218853164, -0.5029860367700724),
|
870
|
+
new Grad4(0.6740059517812944, 0.3239847771997537, 0.3239847771997537, -0.5794684678643381),
|
871
|
+
new Grad4(0.03381941603233842, 0.03381941603233842, 0.03381941603233842, 0.9982828964265062),
|
872
|
+
new Grad4(-0.044802370851755174, -0.044802370851755174, 0.508629699630796, 0.8586508742123365),
|
873
|
+
new Grad4(-0.044802370851755174, 0.508629699630796, -0.044802370851755174, 0.8586508742123365),
|
874
|
+
new Grad4(-0.12128480194602098, 0.4321472685365301, 0.4321472685365301, 0.7821684431180708),
|
875
|
+
new Grad4(0.508629699630796, -0.044802370851755174, -0.044802370851755174, 0.8586508742123365),
|
876
|
+
new Grad4(0.4321472685365301, -0.12128480194602098, 0.4321472685365301, 0.7821684431180708),
|
877
|
+
new Grad4(0.4321472685365301, 0.4321472685365301, -0.12128480194602098, 0.7821684431180708),
|
878
|
+
new Grad4(0.37968289875261624, 0.37968289875261624, 0.37968289875261624, 0.753341017856078),
|
879
|
+
new Grad4(0.03381941603233842, 0.03381941603233842, 0.9982828964265062, 0.03381941603233842),
|
880
|
+
new Grad4(-0.044802370851755174, 0.044802370851755174, 0.8586508742123365, 0.508629699630796),
|
881
|
+
new Grad4(-0.044802370851755174, 0.508629699630796, 0.8586508742123365, -0.044802370851755174),
|
882
|
+
new Grad4(-0.12128480194602098, 0.4321472685365301, 0.7821684431180708, 0.4321472685365301),
|
883
|
+
new Grad4(0.508629699630796, -0.044802370851755174, 0.8586508742123365, -0.044802370851755174),
|
884
|
+
new Grad4(0.4321472685365301, -0.12128480194602098, 0.7821684431180708, 0.4321472685365301),
|
885
|
+
new Grad4(0.4321472685365301, 0.4321472685365301, 0.7821684431180708, -0.12128480194602098),
|
886
|
+
new Grad4(0.37968289875261624, 0.37968289875261624, 0.753341017856078, 0.37968289875261624),
|
887
|
+
new Grad4(0.03381941603233842, 0.9982828964265062, 0.03381941603233842, 0.03381941603233842),
|
888
|
+
new Grad4(-0.044802370851755174, 0.8586508742123365, -0.044802370851755174, 0.508629699630796),
|
889
|
+
new Grad4(-0.044802370851755174, 0.8586508742123365, 0.508629699630796, -0.044802370851755174),
|
890
|
+
new Grad4(-0.12128480194602098, 0.7821684431180708, 0.4321472685365301, 0.4321472685365301),
|
891
|
+
new Grad4(0.508629699630796, 0.8586508742123365, -0.044802370851755174, -0.044802370851755174),
|
892
|
+
new Grad4(0.4321472685365301, 0.7821684431180708, -0.12128480194602098, 0.4321472685365301),
|
893
|
+
new Grad4(0.4321472685365301, 0.7821684431180708, 0.4321472685365301, -0.12128480194602098),
|
894
|
+
new Grad4(0.37968289875261624, 0.753341017856078, 0.37968289875261624, 0.37968289875261624),
|
895
|
+
new Grad4(0.9982828964265062, 0.03381941603233842, 0.03381941603233842, 0.03381941603233842),
|
896
|
+
new Grad4(0.8586508742123365, -0.044802370851755174, -0.044802370851755174, 0.508629699630796),
|
897
|
+
new Grad4(0.8586508742123365, -0.044802370851755174, 0.508629699630796, -0.044802370851755174),
|
898
|
+
new Grad4(0.7821684431180708, -0.12128480194602098, 0.4321472685365301, 0.4321472685365301),
|
899
|
+
new Grad4(0.8586508742123365, 0.508629699630796, -0.044802370851755174, -0.044802370851755174),
|
900
|
+
new Grad4(0.7821684431180708, 0.4321472685365301, -0.12128480194602098, 0.4321472685365301),
|
901
|
+
new Grad4(0.7821684431180708, 0.4321472685365301, 0.4321472685365301, -0.12128480194602098),
|
902
|
+
new Grad4(0.753341017856078, 0.37968289875261624, 0.37968289875261624, 0.37968289875261624)
|
903
|
+
};
|
904
|
+
for (Grad4 grad41 : grad4) {
|
905
|
+
grad41.dx /= N4;
|
906
|
+
grad41.dy /= N4;
|
907
|
+
grad41.dz /= N4;
|
908
|
+
grad41.dw /= N4;
|
909
|
+
}
|
910
|
+
for (int i = 0; i < PSIZE; i++) {
|
911
|
+
GRADIENTS_4D[i] = grad4[i % grad4.length];
|
912
|
+
}
|
913
|
+
}
|
813
914
|
}
|