forked from thargor6/JWildfire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Flam4_3dKernal_TemplateJWF.cu
5129 lines (4509 loc) · 159 KB
/
Flam4_3dKernal_TemplateJWF.cu
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
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
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
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
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
/*
Copyright 2008 Steven Brodhead, Jr.
Copyright 2011-2016 Steven Brodhead, Sr., Centcom Inc.
// All rights reserved.
// Fractal Architect Render Engine - a GPU accelerated flame fractal renderer written in C++
//
// This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
// General Public License as published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This software 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along with this software;
// if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
/*
Extended version for the use from within JWildfire7+. Requires the extended FACLRenderJWF.exe as client to execute.
See https://bitbucket.org/amaschke/faengine/src/JWildfireExperiments/ for more details.
Copyright 2021 Andreas Maschke, with contributions made by Jesus Sosa.
*/
// the following switches are made to help to keep the kernel small and include only features which are actually used (="poor module system")
// activate noise features
// #define ADD_FEATURE_CELLULAR_NOISE
// #define ADD_FEATURE_CUBIC_NOISE
// #define ADD_FEATURE_PERLIN_NOISE
// #define ADD_FEATURE_SIMPLEX_NOISE
// #define ADD_FEATURE_VALUE_NOISE
// #define ADD_FEATURE_WHITE_NOISE
// activate wfields, please note that you must ensure to enable all the required noise types, otherwise all noise (and so the wfield) will be zero
// #define ADD_FEATURE_WFIELDS
// #define ADD_FEATURE_WFIELDS_JITTER
// activate additional features
// #define ADD_FEATURE_DOF
// Usually, these switches are set by the client by replacing the following placeholder:
__GLOBAL_DEFINITIONS__
#if defined(ADD_FEATURE_CELLULAR_NOISE) || defined(ADD_FEATURE_CUBIC_NOISE) || defined(ADD_FEATURE_PERLIN_NOISE) || defined(ADD_FEATURE_SIMPLEX_NOISE) || defined(ADD_FEATURE_VALUE_NOISE) || defined(ADD_FEATURE_WHITE_NOISE)
#define ADD_FEATURE_FAST_NOISE
#else
#undef ADD_FEATURE_FAST_NOISE
#endif
#define NUM_ITERATIONS 100
// #define DENSITY_KERNAL_RADIUS 7
#define DENSITY_KERNAL_RADIUS_16KB 7
#define DENSITY_KERNAL_RADIUS_32KB 14
#define DENSITY_KERNAL_RADIUS_48KB 19
#define NUM_FRAMES 160
#define FRAME_RATE 30
#define BITRATE 54000000
#ifndef SUPERSAMPLE_WIDTH
#define SUPERSAMPLE_WIDTH 0.25f
#endif
#ifndef FLAMEDATA_H
#define FLAMEDATA_H
#define MAX_XFORMS 58 // We're limited to 64KB constant memory for compute capacity 1.0.
// All xForms must fit in this.
#define NO_RGBA_CONSTRUCTOR
#define uint unsigned
#define ulong unsigned long
#define M_PI_F 3.141592653589793f
#define M_PI_2_F 1.5707963267949f
#define M_PI_4_F 0.78539816339745f
#define M_1_PI_F 0.31830988618379f
#define M_2_PI_F 0.63661977236758f
#define JWF_EXTENSIONS
#ifndef RGBA_H
#define RGBA_H
struct __align__(16) rgba
{
float r;
float g;
float b;
float a;
};
#endif
#ifdef JWF_EXTENSIONS
__device__ float sqrtf_safe(float x) {
if (x <= 0.0f)
return 0.0f;
else
return sqrtf(x);
}
__device__ float lerpf(float a, float b, float p) {
return a + (b - a) * p;
}
__device__ float blerpf(float c00, float c10, float c01, float c11, float tx, float ty) {
return lerpf(lerpf(c00, c10, tx), lerpf(c01, c11, tx), ty);
}
__device__ float fracf(float x) {
return x - truncf(x);
}
#define EPSILON 0.000000001f
#ifdef ADD_FEATURE_FAST_NOISE
//--------------------------------- Noise (for supporting wfields) ----------------------------------
// partial CUDA-port of FastNoise: https://github.com/Auburn/FastNoise_Java
// restrictions:
// - only 3d-noise is supported
// - and NoiseLookup-return-type of cellular noise is not supported because it is very complicated to set up (at least on GPU, in comparison to all other types)
typedef enum {Value, ValueFractal, Perlin, PerlinFractal, Simplex, SimplexFractal, Cellular, WhiteNoise, Cubic, CubicFractal} NoiseType;
typedef enum {Linear, Hermite, Quintic} Interp;
typedef enum {FBM, Billow, RigidMulti} FractalType;
typedef enum {Euclidean, Manhattan, Natural} CellularDistanceFunction;
typedef enum {CellValue, Distance, Distance2, Distance2Add, Distance2Sub, Distance2Mul, Distance2Div} CellularReturnType;
typedef struct __align__(8)
{
int m_seed; // seed used for all noise types
// Default: 1337
float m_frequency; // frequency for all noise types
// Default: 0.01
Interp m_interp; // possible interpolation methods (lowest to highest quality): Linear, Hermite, Quintic
// used in Value, Gradient Noise and Position Perturbing
// Default: Quintic
NoiseType m_noiseType; // Default: Simplex
int m_octaves; // octave count for all fractal noise types
// Default: 3
float m_lacunarity; // octave lacunarity for all fractal noise types
// Default: 2.0
float m_gain; // octave gain for all fractal noise types
// Default: 0.5
FractalType m_fractalType; // method for combining octaves in all fractal noise types
// Default: FBM
CellularDistanceFunction m_cellularDistanceFunction; // distance function used in cellular noise calculations
// Default: Euclidean
CellularReturnType m_cellularReturnType; // return type from cellular noise calculations
// Default: CellValue
float m_fractalBounding;
} FastNoise;
__device__ void calculateFractalBounding(FastNoise* n) {
float amp = n->m_gain;
float ampFractal = 1;
for (int i = 1; i < n->m_octaves; i++) {
ampFractal += amp;
amp *= n->m_gain;
}
n->m_fractalBounding = 1 / ampFractal;
}
__device__ void fastNoise_init(FastNoise* n) {
n->m_seed = 1337;
n->m_frequency = 0.01f;
n->m_interp = Quintic;
n->m_noiseType = Simplex;
n->m_octaves = 3;
n->m_lacunarity = 2.0f;
n->m_gain = 0.5f;
n->m_fractalType = FBM;
n->m_cellularDistanceFunction = Euclidean;
n->m_cellularReturnType = Distance;
calculateFractalBounding(n);
}
__device__ void fastNoise_prepare(FastNoise* n) {
calculateFractalBounding(n);
}
__device__ int fastFloor(float f) {
return (f >= 0 ? (int) f : (int) f - 1);
}
__device__ int fastRound(float f) {
return (f >= 0) ? (int) (f + (float) 0.5) : (int) (f - (float) 0.5);
}
__device__ float lerp(float a, float b, float t) {
return a + t * (b - a);
}
__device__ float interpHermiteFunc(float t) {
return t * t * (3 - 2 * t);
}
__device__ float interpQuinticFunc(float t) {
return t * t * t * (t * (t * 6 - 15) + 10);
}
__device__ float cubicLerp(float a, float b, float c, float d, float t) {
float p = (d - c) - (a - b);
return t * t * t * p + t * t * ((a - b) - p) + t * (c - a) + b;
}
__device__ __constant__ float GRAD_3D_x[16] = { 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0, 1, 0, -1, 0 };
__device__ __constant__ float GRAD_3D_y[16] = { 1, 1, -1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1 };
__device__ __constant__ float GRAD_3D_z[16] = { 0, 0, 0, 0, 1, 1, -1, -1, 1, 1, -1, -1, 0, 1, 0, -1 };
// Hashing
__device__ __constant__ int X_PRIME = 1619;
__device__ __constant__ int Y_PRIME = 31337;
__device__ __constant__ int Z_PRIME = 6971;
__device__ __constant__ int W_PRIME = 1013;
__device__ int hash2D(int seed, int x, int y) {
int hash = seed;
hash ^= X_PRIME * x;
hash ^= Y_PRIME * y;
hash = hash * hash * hash * 60493;
hash = (hash >> 13) ^ hash;
return hash;
}
__device__ int hash3D(int seed, int x, int y, int z) {
int hash = seed;
hash ^= X_PRIME * x;
hash ^= Y_PRIME * y;
hash ^= Z_PRIME * z;
hash = hash * hash * hash * 60493;
hash = (hash >> 13) ^ hash;
return hash;
}
__device__ int hash4D(int seed, int x, int y, int z, int w) {
int hash = seed;
hash ^= X_PRIME * x;
hash ^= Y_PRIME * y;
hash ^= Z_PRIME * z;
hash ^= W_PRIME * w;
hash = hash * hash * hash * 60493;
hash = (hash >> 13) ^ hash;
return hash;
}
__device__ float valCoord2D(int seed, int x, int y) {
int n = seed;
n ^= X_PRIME * x;
n ^= Y_PRIME * y;
return (n * n * n * 60493) / (float) 2147483648.0;
}
__device__ float valCoord3D(int seed, int x, int y, int z) {
int n = seed;
n ^= X_PRIME * x;
n ^= Y_PRIME * y;
n ^= Z_PRIME * z;
return (n * n * n * 60493) / (float) 2147483648.0;
}
__device__ float valCoord4D(int seed, int x, int y, int z, int w) {
int n = seed;
n ^= X_PRIME * x;
n ^= Y_PRIME * y;
n ^= Z_PRIME * z;
n ^= W_PRIME * w;
return (n * n * n * 60493) / (float) 2147483648.0;
}
__device__ float gradCoord3D(int seed, int x, int y, int z, float xd, float yd, float zd) {
int hash = seed;
hash ^= X_PRIME * x;
hash ^= Y_PRIME * y;
hash ^= Z_PRIME * z;
hash = hash * hash * hash * 60493;
hash = (hash >> 13) ^ hash;
int idx = hash & 15;
return xd * GRAD_3D_x[idx] + yd * GRAD_3D_y[idx] + zd * GRAD_3D_z[idx];
}
__device__ float gradCoord4D(int seed, int x, int y, int z, int w, float xd, float yd, float zd, float wd) {
int hash = seed;
hash ^= X_PRIME * x;
hash ^= Y_PRIME * y;
hash ^= Z_PRIME * z;
hash ^= W_PRIME * w;
hash = hash * hash * hash * 60493;
hash = (hash >> 13) ^ hash;
hash &= 31;
float a = yd, b = zd, c = wd; // X,Y,Z
switch (hash >> 3) { // OR, DEPENDING ON HIGH ORDER 2 BITS:
case 1:
a = wd;
b = xd;
c = yd;
break; // W,X,Y
case 2:
a = zd;
b = wd;
c = xd;
break; // Z,W,X
case 3:
a = yd;
b = zd;
c = wd;
break; // Y,Z,W
}
return ((hash & 4) == 0 ? -a : a) + ((hash & 2) == 0 ? -b : b) + ((hash & 1) == 0 ? -c : c);
}
// White Noise
#ifdef ADD_FEATURE_WHITE_NOISE
__device__ int floatToIntBits(float x)
{
union {
float f; // assuming 32-bit IEEE 754 single-precision
int i; // assuming 32-bit 2's complement int
} u;
if (isnan(x)) {
return 0x7fc00000;
} else {
u.f = x;
return u.i;
}
}
__device__ int floatCast2Int(float f) {
int i = floatToIntBits(f);
return i ^ (i >> 16);
}
#endif // ADD_FEATURE_WHITE_NOISE
#ifdef ADD_FEATURE_WHITE_NOISE
__device__ float getWhiteNoise(FastNoise* n, float x, float y, float z) {
int xi = floatCast2Int(x);
int yi = floatCast2Int(y);
int zi = floatCast2Int(z);
return valCoord3D(n->m_seed, xi, yi, zi);
}
__device__ float getWhiteNoiseInt(FastNoise* n, int x, int y, int z) {
return valCoord3D(n->m_seed, x, y, z);
}
#endif // ADD_FEATURE_WHITE_NOISE
// Value Noise
#ifdef ADD_FEATURE_VALUE_NOISE
__device__ float singleValue(FastNoise* n,int seed, float x, float y, float z) {
int x0 = fastFloor(x);
int y0 = fastFloor(y);
int z0 = fastFloor(z);
int x1 = x0 + 1;
int y1 = y0 + 1;
int z1 = z0 + 1;
float xs, ys, zs;
switch (n->m_interp) {
default:
case Linear:
xs = x - x0;
ys = y - y0;
zs = z - z0;
break;
case Hermite:
xs = interpHermiteFunc(x - x0);
ys = interpHermiteFunc(y - y0);
zs = interpHermiteFunc(z - z0);
break;
case Quintic:
xs = interpQuinticFunc(x - x0);
ys = interpQuinticFunc(y - y0);
zs = interpQuinticFunc(z - z0);
break;
}
float xf00 = lerp(valCoord3D(seed, x0, y0, z0), valCoord3D(seed, x1, y0, z0), xs);
float xf10 = lerp(valCoord3D(seed, x0, y1, z0), valCoord3D(seed, x1, y1, z0), xs);
float xf01 = lerp(valCoord3D(seed, x0, y0, z1), valCoord3D(seed, x1, y0, z1), xs);
float xf11 = lerp(valCoord3D(seed, x0, y1, z1), valCoord3D(seed, x1, y1, z1), xs);
float yf0 = lerp(xf00, xf10, ys);
float yf1 = lerp(xf01, xf11, ys);
return lerp(yf0, yf1, zs);
}
__device__ float singleValueFractalFBM(FastNoise* n, float x, float y, float z) {
int seed = n->m_seed;
float sum = singleValue(n, seed, x, y, z);
float amp = 1;
for (int i = 1; i < n->m_octaves; i++) {
x *= n->m_lacunarity;
y *= n->m_lacunarity;
z *= n->m_lacunarity;
amp *= n->m_gain;
sum += singleValue(n, ++seed, x, y, z) * amp;
}
return sum * n->m_fractalBounding;
}
__device__ float singleValueFractalBillow(FastNoise* n, float x, float y, float z) {
int seed = n->m_seed;
float sum = fabsf(singleValue(n, seed, x, y, z)) * 2 - 1;
float amp = 1;
for (int i = 1; i < n->m_octaves; i++) {
x *= n->m_lacunarity;
y *= n->m_lacunarity;
z *= n->m_lacunarity;
amp *= n->m_gain;
sum += (fabsf(singleValue(n, ++seed, x, y, z)) * 2 - 1) * amp;
}
return sum * n->m_fractalBounding;
}
__device__ float singleValueFractalRigidMulti(FastNoise* n, float x, float y, float z) {
int seed = n->m_seed;
float sum = 1 - fabsf(singleValue(n, seed, x, y, z));
float amp = 1;
for (int i = 1; i < n->m_octaves; i++) {
x *= n->m_lacunarity;
y *= n->m_lacunarity;
z *= n->m_lacunarity;
amp *= n->m_gain;
sum -= (1 - fabsf(singleValue(n, ++seed, x, y, z))) * amp;
}
return sum;
}
__device__ float getValue(FastNoise* n, float x, float y, float z) {
return singleValue(n, n->m_seed, x * n->m_frequency, y * n->m_frequency, z * n->m_frequency);
}
__device__ float getValueFractal(FastNoise* n, float x, float y, float z) {
x *= n->m_frequency;
y *= n->m_frequency;
z *= n->m_frequency;
switch (n->m_fractalType) {
case FBM:
return singleValueFractalFBM(n, x, y, z);
case Billow:
return singleValueFractalBillow(n, x, y, z);
case RigidMulti:
return singleValueFractalRigidMulti(n, x, y, z);
default:
return 0;
}
}
#endif // ADD_FEATURE_VALUE_NOISE
#ifdef ADD_FEATURE_PERLIN_NOISE
// Perlin Noise
__device__ float singlePerlin(FastNoise* n, int seed, float x, float y, float z) {
int x0 = fastFloor(x);
int y0 = fastFloor(y);
int z0 = fastFloor(z);
int x1 = x0 + 1;
int y1 = y0 + 1;
int z1 = z0 + 1;
float xs, ys, zs;
switch (n->m_interp) {
default:
case Linear:
xs = x - x0;
ys = y - y0;
zs = z - z0;
break;
case Hermite:
xs = interpHermiteFunc(x - x0);
ys = interpHermiteFunc(y - y0);
zs = interpHermiteFunc(z - z0);
break;
case Quintic:
xs = interpQuinticFunc(x - x0);
ys = interpQuinticFunc(y - y0);
zs = interpQuinticFunc(z - z0);
break;
}
float xd0 = x - x0;
float yd0 = y - y0;
float zd0 = z - z0;
float xd1 = xd0 - 1;
float yd1 = yd0 - 1;
float zd1 = zd0 - 1;
float xf00 = lerp(gradCoord3D(seed, x0, y0, z0, xd0, yd0, zd0), gradCoord3D(seed, x1, y0, z0, xd1, yd0, zd0), xs);
float xf10 = lerp(gradCoord3D(seed, x0, y1, z0, xd0, yd1, zd0), gradCoord3D(seed, x1, y1, z0, xd1, yd1, zd0), xs);
float xf01 = lerp(gradCoord3D(seed, x0, y0, z1, xd0, yd0, zd1), gradCoord3D(seed, x1, y0, z1, xd1, yd0, zd1), xs);
float xf11 = lerp(gradCoord3D(seed, x0, y1, z1, xd0, yd1, zd1), gradCoord3D(seed, x1, y1, z1, xd1, yd1, zd1), xs);
float yf0 = lerp(xf00, xf10, ys);
float yf1 = lerp(xf01, xf11, ys);
return lerp(yf0, yf1, zs);
}
__device__ float getPerlin(FastNoise* n, float x, float y, float z) {
return singlePerlin(n, n->m_seed, x * n->m_frequency, y * n->m_frequency, z * n->m_frequency);
}
__device__ float singlePerlinFractalFBM(FastNoise* n, float x, float y, float z) {
int seed = n->m_seed;
float sum = singlePerlin(n, seed, x, y, z);
float amp = 1;
for (int i = 1; i < n->m_octaves; i++) {
x *= n->m_lacunarity;
y *= n->m_lacunarity;
z *= n->m_lacunarity;
amp *= n->m_gain;
sum += singlePerlin(n, ++seed, x, y, z) * amp;
}
return sum * n->m_fractalBounding;
}
__device__ float singlePerlinFractalBillow(FastNoise* n, float x, float y, float z) {
int seed = n->m_seed;
float sum = fabsf(singlePerlin(n, seed, x, y, z)) * 2 - 1;
float amp = 1;
for (int i = 1; i < n->m_octaves; i++) {
x *= n->m_lacunarity;
y *= n->m_lacunarity;
z *= n->m_lacunarity;
amp *= n->m_gain;
sum += (fabsf(singlePerlin(n, ++seed, x, y, z)) * 2 - 1) * amp;
}
return sum * n->m_fractalBounding;
}
__device__ float singlePerlinFractalRigidMulti(FastNoise* n, float x, float y, float z) {
int seed = n->m_seed;
float sum = 1 - fabsf(singlePerlin(n, seed, x, y, z));
float amp = 1;
for (int i = 1; i < n->m_octaves; i++) {
x *= n->m_lacunarity;
y *= n->m_lacunarity;
z *= n->m_lacunarity;
amp *= n->m_gain;
sum -= (1 - fabsf(singlePerlin(n, ++seed, x, y, z))) * amp;
}
return sum;
}
__device__ float getPerlinFractal(FastNoise* n, float x, float y, float z) {
x *= n->m_frequency;
y *= n->m_frequency;
z *= n->m_frequency;
switch (n->m_fractalType) {
case FBM:
return singlePerlinFractalFBM(n, x, y, z);
case Billow:
return singlePerlinFractalBillow(n, x, y, z);
case RigidMulti:
return singlePerlinFractalRigidMulti(n, x, y, z);
default:
return 0;
}
}
#endif // ADD_FEATURE_PERLIN_NOISE
// Simplex Noise
#ifdef ADD_FEATURE_SIMPLEX_NOISE
__device__ __constant__ float F3 = (float) (1.0 / 3.0);
__device__ __constant__ float G3 = (float) (1.0 / 6.0);
__device__ __constant__ float G33 =(float) ((1.0 / 6.0) * 3 - 1);
#endif // ADD_FEATURE_SIMPLEX_NOISE
#ifdef ADD_FEATURE_SIMPLEX_NOISE
__device__ float singleSimplex(int seed, float x, float y, float z) {
float t = (x + y + z) * F3;
int i = fastFloor(x + t);
int j = fastFloor(y + t);
int k = fastFloor(z + t);
t = (i + j + k) * G3;
float x0 = x - (i - t);
float y0 = y - (j - t);
float z0 = z - (k - t);
int i1, j1, k1;
int i2, j2, k2;
if (x0 >= y0) {
if (y0 >= z0) {
i1 = 1;
j1 = 0;
k1 = 0;
i2 = 1;
j2 = 1;
k2 = 0;
} else if (x0 >= z0) {
i1 = 1;
j1 = 0;
k1 = 0;
i2 = 1;
j2 = 0;
k2 = 1;
} else // x0 < z0
{
i1 = 0;
j1 = 0;
k1 = 1;
i2 = 1;
j2 = 0;
k2 = 1;
}
} else // x0 < y0
{
if (y0 < z0) {
i1 = 0;
j1 = 0;
k1 = 1;
i2 = 0;
j2 = 1;
k2 = 1;
} else if (x0 < z0) {
i1 = 0;
j1 = 1;
k1 = 0;
i2 = 0;
j2 = 1;
k2 = 1;
} else // x0 >= z0
{
i1 = 0;
j1 = 1;
k1 = 0;
i2 = 1;
j2 = 1;
k2 = 0;
}
}
float x1 = x0 - i1 + G3;
float y1 = y0 - j1 + G3;
float z1 = z0 - k1 + G3;
float x2 = x0 - i2 + F3;
float y2 = y0 - j2 + F3;
float z2 = z0 - k2 + F3;
float x3 = x0 + G33;
float y3 = y0 + G33;
float z3 = z0 + G33;
float n0, n1, n2, n3;
t = (float) 0.6 - x0 * x0 - y0 * y0 - z0 * z0;
if (t < 0) n0 = 0;
else {
t *= t;
n0 = t * t * gradCoord3D(seed, i, j, k, x0, y0, z0);
}
t = (float) 0.6 - x1 * x1 - y1 * y1 - z1 * z1;
if (t < 0) n1 = 0;
else {
t *= t;
n1 = t * t * gradCoord3D(seed, i + i1, j + j1, k + k1, x1, y1, z1);
}
t = (float) 0.6 - x2 * x2 - y2 * y2 - z2 * z2;
if (t < 0) n2 = 0;
else {
t *= t;
n2 = t * t * gradCoord3D(seed, i + i2, j + j2, k + k2, x2, y2, z2);
}
t = (float) 0.6 - x3 * x3 - y3 * y3 - z3 * z3;
if (t < 0) n3 = 0;
else {
t *= t;
n3 = t * t * gradCoord3D(seed, i + 1, j + 1, k + 1, x3, y3, z3);
}
return 32 * (n0 + n1 + n2 + n3);
}
__device__ float getSimplex(FastNoise* n, float x, float y, float z) {
return singleSimplex(n->m_seed, x * n->m_frequency, y * n->m_frequency, z * n->m_frequency);
}
__device__ float singleSimplexFractalFBM(FastNoise* n, float x, float y, float z) {
int seed = n->m_seed;
float sum = singleSimplex(seed, x, y, z);
float amp = 1;
for (int i = 1; i < n->m_octaves; i++) {
x *= n->m_lacunarity;
y *= n->m_lacunarity;
z *= n->m_lacunarity;
amp *= n->m_gain;
sum += singleSimplex(++seed, x, y, z) * amp;
}
return sum * n->m_fractalBounding;
}
__device__ float singleSimplexFractalBillow(FastNoise* n, float x, float y, float z) {
int seed = n->m_seed;
float sum = fabsf(singleSimplex(seed, x, y, z)) * 2 - 1;
float amp = 1;
for (int i = 1; i < n->m_octaves; i++) {
x *= n->m_lacunarity;
y *= n->m_lacunarity;
z *= n->m_lacunarity;
amp *= n->m_gain;
sum += (fabsf(singleSimplex(++seed, x, y, z)) * 2 - 1) * amp;
}
return sum * n->m_fractalBounding;
}
__device__ float singleSimplexFractalRigidMulti(FastNoise* n, float x, float y, float z) {
int seed = n->m_seed;
float sum = 1 - fabsf(singleSimplex(seed, x, y, z));
float amp = 1;
for (int i = 1; i < n->m_octaves; i++) {
x *= n->m_lacunarity;
y *= n->m_lacunarity;
z *= n->m_lacunarity;
amp *= n->m_gain;
sum -= (1 - fabsf(singleSimplex(++seed, x, y, z))) * amp;
}
return sum;
}
__device__ float getSimplexFractal(FastNoise* n, float x, float y, float z) {
x *= n->m_frequency;
y *= n->m_frequency;
z *= n->m_frequency;
switch (n->m_fractalType) {
case FBM:
return singleSimplexFractalFBM(n, x, y, z);
case Billow:
return singleSimplexFractalBillow(n, x, y, z);
case RigidMulti:
return singleSimplexFractalRigidMulti(n, x, y, z);
default:
return 0;
}
}
#endif // ADD_FEATURE_SIMPLEX_NOISE
#ifdef ADD_FEATURE_SIMPLEX_NOISE
__device__ __constant__ float F2 = (float) (1.0 / 2.0);
__device__ __constant__ float G2 = (float) (1.0 / 4.0);
#endif
// Cubic Noise
#ifdef ADD_FEATURE_CUBIC_NOISE
__device__ __constant__ float CUBIC_3D_BOUNDING = 1 / (float) (1.5 * 1.5 * 1.5);
__device__ float singleCubic(FastNoise* n, int seed, float x, float y, float z) {
int x1 = fastFloor(x);
int y1 = fastFloor(y);
int z1 = fastFloor(z);
int x0 = x1 - 1;
int y0 = y1 - 1;
int z0 = z1 - 1;
int x2 = x1 + 1;
int y2 = y1 + 1;
int z2 = z1 + 1;
int x3 = x1 + 2;
int y3 = y1 + 2;
int z3 = z1 + 2;
float xs = x - (float) x1;
float ys = y - (float) y1;
float zs = z - (float) z1;
return cubicLerp(
cubicLerp(
cubicLerp(valCoord3D(seed, x0, y0, z0), valCoord3D(seed, x1, y0, z0), valCoord3D(seed, x2, y0, z0), valCoord3D(seed, x3, y0, z0), xs),
cubicLerp(valCoord3D(seed, x0, y1, z0), valCoord3D(seed, x1, y1, z0), valCoord3D(seed, x2, y1, z0), valCoord3D(seed, x3, y1, z0), xs),
cubicLerp(valCoord3D(seed, x0, y2, z0), valCoord3D(seed, x1, y2, z0), valCoord3D(seed, x2, y2, z0), valCoord3D(seed, x3, y2, z0), xs),
cubicLerp(valCoord3D(seed, x0, y3, z0), valCoord3D(seed, x1, y3, z0), valCoord3D(seed, x2, y3, z0), valCoord3D(seed, x3, y3, z0), xs),
ys),
cubicLerp(
cubicLerp(valCoord3D(seed, x0, y0, z1), valCoord3D(seed, x1, y0, z1), valCoord3D(seed, x2, y0, z1), valCoord3D(seed, x3, y0, z1), xs),
cubicLerp(valCoord3D(seed, x0, y1, z1), valCoord3D(seed, x1, y1, z1), valCoord3D(seed, x2, y1, z1), valCoord3D(seed, x3, y1, z1), xs),
cubicLerp(valCoord3D(seed, x0, y2, z1), valCoord3D(seed, x1, y2, z1), valCoord3D(seed, x2, y2, z1), valCoord3D(seed, x3, y2, z1), xs),
cubicLerp(valCoord3D(seed, x0, y3, z1), valCoord3D(seed, x1, y3, z1), valCoord3D(seed, x2, y3, z1), valCoord3D(seed, x3, y3, z1), xs),
ys),
cubicLerp(
cubicLerp(valCoord3D(seed, x0, y0, z2), valCoord3D(seed, x1, y0, z2), valCoord3D(seed, x2, y0, z2), valCoord3D(seed, x3, y0, z2), xs),
cubicLerp(valCoord3D(seed, x0, y1, z2), valCoord3D(seed, x1, y1, z2), valCoord3D(seed, x2, y1, z2), valCoord3D(seed, x3, y1, z2), xs),
cubicLerp(valCoord3D(seed, x0, y2, z2), valCoord3D(seed, x1, y2, z2), valCoord3D(seed, x2, y2, z2), valCoord3D(seed, x3, y2, z2), xs),
cubicLerp(valCoord3D(seed, x0, y3, z2), valCoord3D(seed, x1, y3, z2), valCoord3D(seed, x2, y3, z2), valCoord3D(seed, x3, y3, z2), xs),
ys),
cubicLerp(
cubicLerp(valCoord3D(seed, x0, y0, z3), valCoord3D(seed, x1, y0, z3), valCoord3D(seed, x2, y0, z3), valCoord3D(seed, x3, y0, z3), xs),
cubicLerp(valCoord3D(seed, x0, y1, z3), valCoord3D(seed, x1, y1, z3), valCoord3D(seed, x2, y1, z3), valCoord3D(seed, x3, y1, z3), xs),
cubicLerp(valCoord3D(seed, x0, y2, z3), valCoord3D(seed, x1, y2, z3), valCoord3D(seed, x2, y2, z3), valCoord3D(seed, x3, y2, z3), xs),
cubicLerp(valCoord3D(seed, x0, y3, z3), valCoord3D(seed, x1, y3, z3), valCoord3D(seed, x2, y3, z3), valCoord3D(seed, x3, y3, z3), xs),
ys),
zs) * CUBIC_3D_BOUNDING;
}
__device__ float getCubic(FastNoise* n, float x, float y, float z) {
return singleCubic(n, n->m_seed, x * n->m_frequency, y * n->m_frequency, z * n->m_frequency);
}
__device__ float singleCubicFractalFBM(FastNoise* n, float x, float y, float z) {
int seed = n->m_seed;
float sum = singleCubic(n, seed, x, y, z);
float amp = 1;
int i = 0;
while (++i < n->m_octaves) {
x *= n->m_lacunarity;
y *= n->m_lacunarity;
z *= n->m_lacunarity;
amp *= n->m_gain;
sum += singleCubic(n, ++seed, x, y, z) * amp;
}
return sum * n->m_fractalBounding;
}
__device__ float singleCubicFractalBillow(FastNoise* n, float x, float y, float z) {
int seed = n->m_seed;
float sum = fabsf(singleCubic(n, seed, x, y, z)) * 2 - 1;
float amp = 1;
int i = 0;
while (++i < n->m_octaves) {
x *= n->m_lacunarity;
y *= n->m_lacunarity;
z *= n->m_lacunarity;
amp *= n->m_gain;
sum += (fabsf(singleCubic(n, ++seed, x, y, z)) * 2 - 1) * amp;
}
return sum * n->m_fractalBounding;
}
__device__ float singleCubicFractalRigidMulti(FastNoise* n, float x, float y, float z) {
int seed = n->m_seed;
float sum = 1 - fabsf(singleCubic(n, seed, x, y, z));
float amp = 1;
int i = 0;
while (++i < n->m_octaves) {
x *= n->m_lacunarity;
y *= n->m_lacunarity;
z *= n->m_lacunarity;
amp *= n->m_gain;
sum -= (1 - fabsf(singleCubic(n, ++seed, x, y, z))) * amp;
}
return sum;
}
__device__ float getCubicFractal(FastNoise* n, float x, float y, float z) {
x *= n->m_frequency;
y *= n->m_frequency;
z *= n->m_frequency;
switch (n->m_fractalType) {
case FBM:
return singleCubicFractalFBM(n, x, y, z);
case Billow:
return singleCubicFractalBillow(n, x, y, z);
case RigidMulti:
return singleCubicFractalRigidMulti(n, x, y, z);
default:
return 0;
}
}
#endif // ADD_FEATURE_CUBIC_NOISE
// Cellular Noise
#ifdef ADD_FEATURE_CELLULAR_NOISE
__device__ __constant__ float CELL_3D_x[] = {
0.1453787434f, -0.01242829687f, 0.2877979582f, -0.07732986802f, 0.1107205875f, 0.2755209141f, 0.294168941f, 0.4000921098f,
-0.1697304074f, -0.1483224484f, 0.2623596946f, -0.2709003183f, -0.03516550699f, -0.1267712655f, 0.02952021915f, -0.2806854217f,
-0.171159547f, 0.2113227183f, -0.1024352839f, -0.3304249877f, 0.2091111325f, 0.344678154f, 0.1984478035f, -0.2929008603f,
-0.1617332831f, -0.3582060271f, -0.1852067326f, 0.3046301062f, -0.03816768434f, -0.4084952196f, -0.02687443361f, -0.03801098351f,
0.2371120802f, 0.4447660503f, 0.01985147278f, 0.4274339143f, -0.2072988631f, -0.3791240978f, -0.2098721267f, 0.01582798878f,
-0.1888129464f, 0.1612988974f, -0.08974491322f, 0.07041229526f, -0.1082925611f, 0.2474100658f, -0.1068836661f, 0.2396452163f,
-0.3063886072f, 0.1593342891f, 0.2709690528f, -0.1519780427f, 0.1699773681f, -0.1986155616f, -0.1887482106f, 0.2659103394f,
-0.08838976154f, -0.04201869311f, -0.3230334656f, 0.2612720941f, 0.385713046f, 0.07654967953f, 0.4317038818f, -0.2890436293f,
-0.2201947582f, 0.4161322773f, 0.2204718095f, -0.1040307469f, -0.1432122615f, 0.3978380468f, -0.2599274663f, 0.4032618332f,
-0.08953470255f, 0.118937202f, 0.02167047076f, -0.3411343612f, 0.3162964612f, 0.2355138889f, -0.02874541518f, -0.2461455173f,
0.04208029445f, 0.2727458746f, -0.1347522818f, 0.3829624424f, -0.3547613644f, 0.2305790207f, -0.08323845599f, 0.2993663085f,
-0.2154865723f, 0.01683355354f, 0.05240429123f, 0.00940104872f, 0.3465688735f, -0.3706867948f, 0.2741169781f, 0.06413433865f,
-0.388187972f, 0.06419469312f, -0.1986120739f, -0.203203009f, -0.1389736354f, -0.06555641638f, -0.2529246486f, 0.1444476522f,
-0.3643780054f, 0.4286142488f, 0.165872923f, 0.2219610524f, 0.04322940318f, -0.08481269795f, 0.1822082075f, -0.3269323334f,
-0.4080485344f, 0.2676025294f, 0.3024892441f, 0.1448494052f, 0.4198402157f, -0.3008872161f, 0.3639310428f, 0.3295806598f,
0.2776259487f, 0.4149000507f, 0.145016715f, 0.09299023471f, 0.1028907093f, 0.2683057049f, -0.4227307273f, -0.1781224702f,
0.4390788626f, 0.2972583585f, -0.1707002821f, 0.3806686614f, -0.1751445661f, -0.2227237566f, 0.1369633021f, -0.3529503428f,
-0.2590744185f, -0.3784019401f, -0.05635805671f, 0.3251428613f, -0.4190995804f, -0.3253150961f, 0.2857945863f, -0.2733604046f,
0.219003657f, 0.3182767252f, -0.03222023115f, -0.3087780231f, -0.06487611647f, 0.3921171432f, -0.1606404506f, -0.03767771199f,
0.1394866832f, -0.4345093872f, -0.1044637494f, 0.2658727501f, 0.2051461999f, -0.266085566f, 0.07849405464f, -0.2160686338f,
-0.185779186f, 0.02492421743f, -0.120167831f, -0.02160084693f, 0.2597670064f, -0.1611553854f, -0.3278896792f, 0.2822734956f,
0.03169341113f, 0.2202613604f, 0.2933396046f, -0.3194922995f, -0.3441586045f, 0.2703645948f, 0.2298568861f, 0.09326603877f,
-0.1116165319f, 0.2172907365f, 0.1991339479f, -0.0541918155f, 0.08871336998f, 0.2787673278f, -0.322166438f, -0.4277366384f,
0.240131882f, 0.1448607981f, -0.3837065682f, -0.4382627882f, -0.37728353f, 0.1259579313f, -0.1406285511f, -0.1580694418f,
0.2477612106f, 0.2916132853f, 0.07365265219f, -0.26126526f, -0.3721862032f, -0.3691191571f, 0.2278441737f, 0.363398169f,
-0.304231482f, -0.3199312232f, 0.2874852279f, -0.1451096801f, 0.3220090754f, -0.1247400865f, -0.2829555867f, 0.1069384374f,
-0.1420661144f, -0.250548338f, 0.3265787872f, 0.07646097258f, 0.3451771584f, 0.298137964f, 0.2812250376f, 0.4390345476f,
0.2148373234f, 0.2595421179f, 0.3182823114f, -0.4089859285f, -0.2826749061f, 0.3483864637f, -0.3226415069f, 0.4330734858f,
-0.08717822568f, -0.2149678299f, -0.2687330705f, 0.2105665099f, 0.4361845915f, 0.05333333359f, -0.05986216652f, 0.3664988455f,
-0.2341015558f, -0.04730947785f, -0.2391566239f, -0.1242081035f, 0.2614832715f, -0.2728794681f, 0.007892900508f, -0.01730330376f,
0.2054835762f, -0.3231994983f, -0.2669545963f, -0.05554372779f, -0.2083935713f, 0.06989323478f, 0.3847566193f, -0.3026215288f,
0.3450735512f, 0.1814473292f, -0.03855010448f, 0.3533670318f, -0.007945601311f, 0.4063099273f, -0.2016773589f, -0.07527055435f,
};
__device__ __constant__ float CELL_3D_y[] = {
-0.4149781685f, -0.1457918398f, -0.02606483451f, 0.2377094325f, -0.3552302079f, 0.2640521179f, 0.1526064594f, -0.2034056362f,
0.3970864695f, -0.3859694688f, -0.2354852944f, 0.3505271138f, 0.3885234328f, 0.1920044036f, 0.4409685861f, -0.266996757f,
0.2141185563f, 0.3902405947f, 0.2128044156f, -0.1566986703f, 0.3133278055f, -0.1944240454f, -0.3214342325f, 0.2262915116f,
0.006314769776f, -0.148303178f, -0.3454119342f, 0.1026310383f, -0.2551766358f, 0.1805950793f, -0.2749741471f, 0.3277859044f,
0.2900386767f, 0.03946930643f, -0.01503183293f, 0.03345994256f, 0.2871414597f, 0.1281177671f, -0.1007087278f, 0.4263894424f,
-0.3160996813f, -0.1974805082f, 0.229148752f, 0.4150230285f, -0.1586061639f, -0.3309414609f, -0.2701644537f, 0.06803600538f,
0.2597428179f, -0.3114350249f, 0.1412648683f, 0.3623355133f, 0.3456012883f, 0.3836276443f, -0.2050154888f, 0.3015631259f,
-0.4288819642f, 0.3099592485f, 0.201549922f, 0.2759854499f, 0.2193460345f, 0.3721732183f, -0.02577753072f, -0.3418179959f,
0.383023377f, -0.1669634289f, 0.02654238946f, 0.3890079625f, 0.371614387f, -0.06206669342f, 0.2616724959f, -0.1124593585f,
-0.3048244735f, -0.2875221847f, -0.03284630549f, 0.2500031105f, 0.3082064153f, -0.3439334267f, -0.3955933019f, 0.02020282325f,
-0.4470439576f, 0.2288471896f, -0.02720848277f, 0.1231931484f, 0.1271702173f, 0.3063895591f, -0.1922245118f, -0.2619918095f,
0.2706747713f, -0.2680655787f, 0.4335128183f, -0.4472890582f, 0.01141914583f, -0.2551104378f, 0.2139972417f, 0.1708718512f,
-0.03973280434f, -0.2803682491f, -0.3391173584f, -0.3871641506f, -0.2775901578f, 0.342253257f, -0.2904227915f, 0.1069184044f,
-0.2447099973f, -0.1358496089f, -0.3136808464f, -0.3658139958f, -0.3832730794f, -0.4404869674f, -0.3953259299f, 0.3036542563f,
0.04227858267f, -0.01299671652f, -0.1009990293f, 0.425921681f, 0.08062320474f, -0.333040905f, -0.1291284382f, 0.0184175994f,
-0.2974929052f, -0.144793182f, -0.0398992945f, -0.299732164f, -0.361266869f, -0.07076041213f, -0.07933161816f, 0.1806857196f,
-0.02841848598f, 0.2382799621f, 0.2215845691f, 0.1471852559f, -0.274887877f, -0.2316778837f, 0.1341343041f, -0.2472893463f,
-0.2985577559f, 0.2199816631f, 0.1485737441f, 0.09666046873f, 0.1406751354f, -0.3080335042f, -0.05796152095f, 0.1973770973f,
0.2410037886f, -0.271342949f, -0.3331161506f, 0.1992794134f, -0.4311322747f, -0.06294284106f, -0.358928121f, -0.2290351443f,
-0.3602213994f, 0.005751117145f, 0.4168128432f, 0.2551943237f, 0.1975390727f, 0.23483312f, -0.3300346342f, 0.05376451292f,
0.2148499206f, -0.3229954284f, 0.4017266681f, -0.06885389554f, 0.3096300784f, -0.09823036005f, 0.1461670309f, 0.03754421121f,
0.347405252f, -0.3460788041f, 0.3031973659f, 0.2453752201f, -0.1698856132f, -0.3574277231f, 0.3744156221f, -0.3170108894f,
-0.2985018719f, -0.3460005203f, 0.3820341668f, -0.2103145071f, 0.2012117383f, 0.3505404674f, 0.3067213525f, 0.132066775f,
-0.1612516055f, -0.2387819045f, -0.2206398454f, -0.09082753406f, 0.05445141085f, 0.348394558f, -0.270877371f, 0.4162931958f,
-0.2927867412f, 0.3312535401f, -0.1666159848f, -0.2422237692f, 0.252790166f, -0.255281188f, -0.3358364886f, -0.2310190248f,
-0.2698452035f, 0.316332536f, 0.1642275508f, 0.3277541114f, 0.0511344108f, -0.04333605335f, -0.3056190617f, 0.3491024667f,
-0.3055376754f, 0.3156466809f, 0.1871229129f, -0.3026690852f, 0.2757120714f, 0.2852657134f, 0.3466716415f, -0.09790429955f,
0.1850172527f, -0.07946825393f, -0.307355516f, -0.04647718411f, 0.07417482322f, 0.225442246f, -0.1420585388f, -0.118868561f,
-0.3909896417f, 0.3939973956f, 0.322686276f, -0.1961317136f, -0.1105517485f, -0.313639498f, 0.1361029153f, 0.2550543014f,
-0.182405731f, -0.4222150243f, -0.2577696514f, 0.4256953395f, -0.3650179274f, -0.3499628774f, -0.1672771315f, 0.2978486637f,
-0.3252600376f, 0.1564282844f, 0.2599343665f, 0.3170813944f, -0.310922837f, -0.3156141536f, -0.1605309138f, -0.3001537679f,
0.08611519592f, -0.2788782453f, 0.09795110726f, 0.2665752752f, 0.140359426f, -0.1491768253f, 0.008816271194f, -0.425643481f,
};
__device__ __constant__ float CELL_3D_z[] = {
-0.0956981749f, -0.4255470325f, -0.3449535616f, 0.3741848704f, -0.2530858567f, -0.238463215f, 0.3044271714f, 0.03244149937f,
-0.1265461359f, 0.1775613147f, 0.2796677792f, -0.07901746678f, 0.2243054374f, 0.3867342179f, 0.08470692262f, 0.2289725438f,
0.3568720405f, -0.07453178509f, -0.3830421561f, 0.2622305365f, -0.2461670583f, -0.2142341261f, -0.2445373252f, 0.2559320961f,
-0.4198838754f, -0.2284613961f, -0.2211087107f, 0.314908508f, -0.3686842991f, 0.05492788837f, 0.3551999201f, 0.3059600725f,