Agent Harness · VibeGit
Agent Harness Публичная копия обвязки агентной разработки: гейты, journeys, скиллы и шаблоны. Без ключей и личных данных.
agent-harness / tools / spells-assets / ue / spells / acid.js 938 строк · изменён 6 нояб., 03:45
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
import * as THREE from 'three' ;
import {
COMMON_GLSL , NOISE_GLSL , ARENA_GLSL , LIGHTS_GLSL , GROUND_GLSL , FX_VERT_HEAD , FX_FRAG_HEAD , FX_OUT_GLSL , FX_BLENDING , MAX_OCCLUDERS ,
} from '../vfx/common.js' ;
import { REFRACT_GLSL } from '../vfx/Refraction.js' ;
import { arenaUniforms } from '../scene/arenaMaterial.js' ;
import { FluidVolume } from '../vfx/FluidVolume.js'
x x x
t x a b a t t t
fx fx
dripE
splashE
rainE
runE
sizzleE
spitE
popE
moteE
fogE
miasmaE
vaporE
steamE
puffE
cloudE
sinkE
glowE
geo
geo
geo
a a geo name a a
geo
bubU
bubbles geo
fx bubU
bubbles
bubbles
fx bubbles
now ring bubbleUntil dirty
i ring o i a fx
o x o o z o now delay
o r o life o o fx
o a drift o a drift o r fx o fx
bubbleUntil bubbleUntil now delay life
dirty
o i ph o
out
o o tau o o tau ph
o
o o tau o o tau o
n
n n fx
k k n k
a fx d fx spread u fx
boil fx big
r boil fx u u
life boil fx fx
x a d z a d r life delay fx fx
poolGeo
pools
i i i
u
m poolGeo
fx arenaUniforms u
m
m
fx m
pools m u
pl pools pl
pl
pl
pl x z
pl
pl x z
pl seed
pl
pl pl pl
u pl
u liquid
u react u p
u glowLin p
u hotLin p
c glowLin
u c c c
fluid fx
fluidStub poolGeo fluid
fluidStub fluidStub
fx fluidStub
x y z radius soot temp burst noise noiseScale seed
vx vy vz radial coupling
f
clouds
i i i
v fx
v v v
clouds v
st
col _a _b
glowLin hotLin _white _hot
kindsColor kindsFog
p
glowLin p
hotLin glowLin _hot
p kindsColor p kindsFog
kindsColor p kindsFog p
dark col p light col p _white drop col p _white
drop dark
light p
light p
col p glowLin col p glowLin
p col p
col p _white col p _white
s fx
s s p
c glowLin
h c hotLin p
h c
h c c c
h
h
h
h s
h
h pos pos pos t
i i i
a t i i b t i
d t i spiral
h i pos d a b pos d b pos d a b t i
vel h
_a vel
j j j
back j
h j pos _a back pos _a back j pos _a back j
u t back u
h pos _a back pos _a back u u pos _a back u u
h
s
i i i
o i a fx sp i fall fx fx
up i fall fx fx
o pos o pos o pos
o a sp o up o a sp
o size i fx
o
s s fall
s s
h s s
s dt
dur s u s dur
u h s
i i i
o i
s o dt o o o
o o dt o o dt o o dt
r s o u o u
s dm
dx o dm dz o dm d dx dz lim r
d lim o o
k lim d
o dm dx k o dm dz k
o o o o
fy r
s o fy o fy o f dt o f o f
h i o o o r
h
s s s
dm fx
d dm x dm z
d
dm dm base d add
dm _b dm x dm z d
p
j fx a dm dm j
j runE dm a dm a
runE dm j dm
runE runE runE k p dt
steamE dm fx dm steamE steamE steamE steamE k p dt
spitE dm dm spitE spitE spitE k p dt
k k
p s st c size p cloud c
name
s s s s s s s
c cloud p
s p
s fx
s s s s glowLin s
name
fx
name
c c c c p
c c c
c
name
s s c size cloud
cloud c p s
c p s
name
s
s s
s s
s s
s
s s
s s
p s st c s size p cloud c
flick c c c
c
k c c
s s p s c size k c k size
moteE c moteE k p dt
vaporE c vaporE vaporE size vaporE size vaporE k p dt
c k flick p
c
s c size c c
dripE c dripE c dripE size dripE p dt
vaporE c vaporE c vaporE size vaporE size vaporE p dt
c flick p
s s dt c fx c
cloud c p s dt flick
c p s dt flick
prev now
now dt
bubbleUntil now bubbles
bubbles
geo
bubU now
bubU
bubU glowLin
bubU hotLin
dirty dirty
pops
i i pops i
o i life o tau now o
life tau life prev o life
r o
r fx
i life popE
popE r popE r popE r
r puffE popE puffE r puffE
pops
pos c size p
size
splashE pos splashE splashE size splashE p
sizzleE pos sizzleE size sizzleE sizzleE p
fogE pos fogE size fogE size fogE size fogE p
vaporE pos vaporE vaporE size vaporE size vaporE p
miasmaE pos miasmaE size miasmaE size miasmaE p
pos pos
size p c fx
size p c fx
fx _a pos size
s pos pos size c
k k k
a fx d fx size
pos a d pos a d p
pos pos p p
c dm fx c dm dm p
s s p s size s pos pos
fx p
fx
fx fx
s
size p pos c
c c c c
left c c
fade left react fade
s s p fade react
s dt
s
s
pos pos size p c
fx
k
fogE pos fogE size fogE size fogE size fogE p k dt
fogE pos fogE size fogE size fogE size fogE p fade dt
vaporE pos vaporE vaporE size vaporE size vaporE p react dt
s react p dt
s
s
x z
dm c fx c
dm fx dm pos dm pos size
a fx d fx
x dm a d z dm a d
a fx d size fx
x pos a d z pos a d
x z
dm fx
dm pos dm pos size
c left dm dm p dt
dm react dt
s
glowT flick p react left
s s dt glowT
s s dt
size p to c
s
f s fluid size size size fluid
f
f to f f to
f
size size
f to to
f p
f f
f _white
f
f glowLin
sd c
f to size to size sd
i i i
a sd i i sd r i sd size ca a sa a
f to ca r i sd size to sa r i sd size sd i
ca sa
v clouds v s v
s
s
s c
s p
cloudE to size to cloudE size cloudE size cloudE p
miasmaE c miasmaE size miasmaE size miasmaE p
s fx
s
v s
v v size v size v v v size
v to to v
s to to size c
sizzleE c sizzleE size sizzleE sizzleE p
s s p s size
to to size p c
fx
fx p
fx
s
size p to c
c c c c
left c c
grow fade left
sink c c
f s
cy size sink f size grow sink
hy size grow sink base f size cy hy
f
seed c k
k f to size to size k p seed
k2 p
k2
f to size to size k2 p seed
front size
i i i
a i seed i w i seed r front w
ca a sa a pulse i
pulse
f to ca r to sa r w size pulse pulse k2 p seed i ca sa
f fade fade
f
s
s to cy to
s hy
s p grow fade s
s sink
s glowLin hotLin
cloudE to cy to cloudE cloudE size cloudE p fade dt
glowE to cy to glowE glowE size glowE p fade dt
sinkE to base to sinkE sinkE sinkE size sinkE p fade grow dt
fogE to to fogE fogE size fogE size fogE p fade grow dt
s s p fade fade
rainE to base to rainE rainE rainE p fade dt
s dt
s fade
s
to to p c
fx
s fade grow p dt
s
s
a fx d fx
to a d to a d
fade dm fx
dm to dm to
dm dm p dt
dm grow fade dt
s
pulse f flick p fade grow
s s dt pulse
s to f cy to
;
const
N_BUB
=
768
;
const
POP
=
0.08
;
const
SURF
=
0.011
;
const
MAX_POOLS
=
3
;
const
BUBBLE_VERT
=
FX_VERT_HEAD
+
COMMON_GLSL
+
`
uniform float uNow;
in vec4 aB0; // surface point xyz, birth (module clock, s)
in vec4 aB1; // radius m, life s, -, seed 0..1
in vec4 aB2; // drift x, drift z (m/s), wobble amplitude m, wobble rad/s
out vec2 vUv;
out vec3 vC; // view-space centre
flat out vec4 vB; // radius m, age 0..1, pop 0..1, seed
flat out float vSurf; // world height of the liquid surface
out float vGain;
void main() {
float tau = uNow - aB0.w, life = aB1.y;
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
vB = vec4(0.0); vC = vec3(0.0); vUv = vec2(0.0); vGain = 0.0; vSurf = 0.0;
if (tau < 0.0 || tau > life + ${ POP . toFixed ( 3 ) } || life <= 0.0) return;
float ph = aB1.w * 6.2832, k = clamp(tau / life, 0.0, 1.0);
vec3 c = aB0.xyz + vec3(aB2.x * tau + aB2.z * sin(aB2.w * tau + ph), 0.0, aB2.y * tau + aB2.z * cos(aB2.w * 0.83 * tau + aB1.w * 11.0));
// swells up out of the liquid, then sits on it as a dome (centre below the surface)
float r = aB1.x * (0.4 + 0.6 * sqrt(min(k * 3.0, 1.0)));
c.y += r * mix(-0.9, -0.3, smoothstep(0.0, 0.3, k));
float pop = clamp((tau - life) / ${ POP . toFixed ( 3 ) } , 0.0, 1.0);
vec3 cv = (viewMatrix * vec4(c, 1.0)).xyz;
float viewZ = -cv.z;
if (viewZ < 0.25) return;
// never below one fx pixel, energy kept
float pxW = 2.0 * viewZ / (projectionMatrix[1][1] * uFxResolution.y);
float rr = max(r, pxW);
vGain = (r / rr) * (r / rr) * smoothstep(0.25, 1.0, viewZ);
float ext = (1.0 + 1.3 * pop) * 1.08; // slack for perspective, room for the spray ring
gl_Position = projectionMatrix * vec4(cv + vec3(position.xy * rr * ext, 0.0), 1.0);
vUv = position.xy * ext;
vC = cv;
vB = vec4(rr, k, pop, aB1.w);
vSurf = aB0.y;
} `
;
const
BUBBLE_FRAG
=
FX_FRAG_HEAD
+
COMMON_GLSL
+
NOISE_GLSL
+
FX_OUT_GLSL
+
`
uniform mat4 projectionMatrix;
uniform samplerCube uSkyCube;
uniform vec3 uSunDir;
uniform vec3 uSunColor;
uniform vec3 uTint; // acid glow, linear (the pool's light from below)
uniform vec3 uHot; // spray of a pop, linear
uniform vec2 uIri; // reflection gain, interference saturation 0..1
in vec2 vUv;
in vec3 vC;
flat in vec4 vB;
flat in float vSurf;
in float vGain;
// Spectrally integrated cos(2 pi opd / lambda) against the CIE XYZ matching functions, with the
// Gaussian fits in Fourier space of Belcour & Barla 2017 ("A Practical Extension to Microfacet
// Theory for the Modeling of Varying Iridescence"), to linear sRGB, normalised so opd 0 is white.
const mat3 XYZ2RGB = mat3(3.2404542, -0.9692660, 0.0556434, -1.5371385, 1.8760108, -0.2040259, -0.4985314, 0.0415560, 1.0572252);
vec3 filmCos(float opd) {
float ph = 6.2831853e-9 * opd; // opd in nm
vec3 var = vec3(4.3278e9, 9.3046e9, 6.6121e9);
vec3 xyz = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13) * sqrt(6.2831853 * var) * cos(vec3(1.6810e6, 1.7953e6, 2.2084e6) * ph) * exp(-var * ph * ph);
xyz.x += 9.7470e-14 * sqrt(6.2831853 * 4.5282e9) * cos(2.2399e6 * ph) * exp(-4.5282e9 * ph * ph);
return XYZ2RGB * (xyz / 1.0685e-7) / vec3(1.2048, 0.9483, 0.9088);
}
// liquid film in air: R(lambda) ~ sin^2(delta / 2), spectral mean 0.5 (1 - filmCos), through Airy's
// F s / (1 + F s). A viscous acid film is microns thick, so it reflects near-white; only as it
// drains thin before the pop do interference colours come up, and black just before it bursts.
vec3 filmReflect(float NoV, float dnm) {
float cosT = sqrt(1.0 - (1.0 - NoV * NoV) / 1.85); // n = 1.36
float R0 = 0.023 + 0.977 * pow(1.0 - NoV, 5.0);
vec3 s = clamp(0.5 * (1.0 - filmCos(2.72 * dnm * cosT)), 0.0, 1.0);
float F = 4.0 * R0 / max((1.0 - R0) * (1.0 - R0), 1e-3);
return F * s / (1.0 + F * s);
}
float film(vec3 n, float age, float seed) {
float sw = noise3(n * 0.23 + vec3(seed * 7.1, uTime * 0.045 + seed, seed * 3.7));
float drain = mix(1.4, 0.5, n.y * 0.5 + 0.5);
return mix(2400.0, 30.0, age * age * age) * drain * (0.4 + 1.2 * sw);
}
// the sky above, the glowing liquid below
vec3 envAt(vec3 r) { return textureLod(uSkyCube, r, 1.5).rgb + uTint * smoothstep(0.15, -0.5, r.y); }
void main() {
float r2 = dot(vUv, vUv), pop = vB.z, viewZ = -vC.z;
if (pop > 0.0) { // burst: a ring of fine spray thrown off the rim
float x = (sqrt(r2) - (1.0 + 1.2 * pop)) / 0.16;
float ring = exp(-x * x) * (1.0 - pop);
if (ring < 0.01) discard;
fxOut(vec3(0.0), 0.0, uHot * ring * vGain * 0.5, vec2(0.0), viewZ);
return;
}
if (r2 >= 1.0) discard;
float z = sqrt(1.0 - r2);
mat3 toW = transpose(mat3(viewMatrix));
vec3 pv = vC + vec3(vUv, z) * vB.x;
vec3 pw = toW * (pv - viewMatrix[3].xyz);
// what is under the liquid surface doesn't show: a dome, anti-aliased over a pixel
float px = 2.0 * viewZ / (projectionMatrix[1][1] * uFxResolution.y);
float above = clamp((pw.y - vSurf) / px + 0.5, 0.0, 1.0);
if (above <= 0.0) discard;
viewZ -= z * vB.x;
vec3 rd = toW * normalize(pv);
vec3 nF = toW * vec3(vUv, z), nB = toW * vec3(vUv, -z);
float NoV = clamp(dot(nF, -rd), 0.0, 1.0);
vec3 RF = filmReflect(NoV, film(nF, vB.y, vB.w)), RB = filmReflect(NoV, film(nB, vB.y, vB.w));
float mF = dot(RF, vec3(0.3333)), mB = dot(RB, vec3(0.3333));
RF = mix(vec3(mF), RF, uIri.y); RB = mix(vec3(mB), RB, uIri.y);
vec3 rF = reflect(rd, nF), rB = reflect(rd, nB);
vec3 col = envAt(rF) * RF + envAt(rB) * RB * (1.0 - RF);
col += uSunColor * pow(max(dot(rF, uSunDir), 0.0), 600.0) * 25.0 * RF;
// the film is the acid itself: tinted, lit through by the pool's glow, most along the rim
float rim = pow(1.0 - NoV, 2.0);
float edge = clamp((1.0 - sqrt(r2)) * vB.x / px * 1.5, 0.0, 1.0) * vGain * above;
float a = clamp((mF + mB) * 0.5 * uIri.x + 0.06 + 0.4 * rim, 0.0, 0.85) * edge;
if (a < 0.002) discard;
fxOut(col * uIri.x * edge / max(a, 1e-4), a, uTint * (0.2 + 1.1 * rim) * edge, vec2(0.0), viewZ);
} `
;
const
POOL_VERT
=
`
out vec3 vW;
void main() {
vec4 w = modelMatrix * vec4(position, 1.0);
vW = w.xyz;
gl_Position = projectionMatrix * viewMatrix * w;
} `
;
const
POOL_FRAG
=
`
uniform vec4 uPoolA; // centre x, z, radius m, liquid 0..1 (how much of the field's acid stands)
uniform vec4 uPoolB; // reaction 0..1, -, corrosion 0..2, seed
uniform vec3 uGlowCol; // linear liquid glow (x glow)
uniform vec3 uHotCol; // linear reaction glow
uniform vec3 uAbsorb; // 1/m
uniform vec3 uSunDir;
uniform vec3 uSunColor;
uniform vec3 uAmbient;
uniform sampler2D uStoneNoise; // the arena's mipmapped noise: r, g fbm (4 cells/tile), a fbm (32)
${ COMMON_GLSL }
${ NOISE_GLSL }
${ ARENA_GLSL }
${ LIGHTS_GLSL }
${ GROUND_GLSL }
${ REFRACT_GLSL }
in vec3 vW;
out vec4 fragColor;
// froth: a jittered grid of bubbles (cell metres), each swelling and popping on its own clock,
// present in a cell with probability dens. Coverage of the dome under p, nb its normal (world).
float froth(vec2 p, float cell, float dens, float rate, out vec3 nb) {
vec2 g = p / cell, i0 = floor(g);
float best = 9.0, cov = 0.0;
nb = vec3(0.0, 1.0, 0.0);
for (int y = -1; y <= 1; y++) for (int x = -1; x <= 1; x++) {
vec2 c = i0 + vec2(float(x), float(y));
vec3 hh = hash33(vec3(c, cell * 97.0));
if (hh.z > dens) continue;
float life = fract(hh.x * 7.31 + uTime * rate * (0.5 + hh.y));
float rad = (0.3 + 0.45 * hh.y) * sqrt(life);
vec2 o = g - c - 0.5 - (hh.yx - 0.5) * 0.6;
float l = length(o), d = l / rad;
if (d < 1.0 && l < best) {
best = l;
nb = vec3(o.x / rad, sqrt(1.0 - d * d), o.y / rad);
cov = 1.0 - smoothstep(0.8, 1.0, d);
}
}
return cov;
}
void main() {
gLightNoShadow = true;
vec2 xz = vW.xz;
// liquid where the field's acid (blurred: surface tension rounds everything off below a few cm),
// shifted by broad noise into lobes, clears the bar: a pool with rounded fingers, stranded beads
// and a soft eating front; h > 0 is liquid
const vec2 e = vec2(0.07, -0.07);
float ac = min(0.25 * (groundB(xz + e.xx).y + groundB(xz + e.xy).y + groundB(xz + e.yx).y + groundB(xz + e.yy).y), 1.6);
vec2 sd = vec2(uPoolB.w, uPoolB.w * 1.7);
float big = texture(uStoneNoise, xz * 0.19 + sd).r, fine = texture(uStoneNoise, xz * 0.8 + sd.yx).a;
float rad = length(xz - uPoolA.xy) / uPoolA.z;
float h = ac * 1.3 * uPoolA.w - 0.45 + (big - 0.5) * 1.1 + (fine - 0.5) * 0.15 - smoothstep(0.7, 1.0, rad) * 2.0;
float depth = 0.004 + 0.016 * smoothstep(0.0, 0.5, h); // m
// every screen derivative before any branch: the AA width and the surface slope (the depth's
// derivatives solved back to world xz: a steep meniscus where it thins at the edge)
float fw = max(fwidth(h), 1e-4);
vec2 dx = dFdx(xz), dy = dFdy(xz);
float hx = dFdx(depth), hy = dFdy(depth), det = dx.x * dy.y - dx.y * dy.x;
vec2 g = abs(det) > 1e-14 ? vec2(hx * dy.y - hy * dx.y, hy * dx.x - hx * dy.x) / det : vec2(0.0);
float pxw = max(length(dx), length(dy)); // pixel footprint (m)
float cov = smoothstep(-fw, fw, h);
float etch = smoothstep(-0.5, -0.03, h) * smoothstep(0.03, 0.15, ac) * min(uPoolB.z, 1.0);
if (cov <= 0.0 && etch <= 0.004) discard;
vec3 v = normalize(cameraPosition - vW);
vec3 under = textureLod(uSceneColor, gl_FragCoord.xy / uResolution, 0.0).rgb;
// the eaten stone round the liquid. The stain itself (rust-brown blotches, etched grain, salt
// bloom) is the floor's own acid response; here it is only damp, darker and browner towards the
// liquid, in soft blotches (a hard threshold on the fine noise printed a camouflage of specks),
// and wet and glossy at the edge
float damp = etch * smoothstep(-0.55, -0.05, h + (big - 0.5) * 0.3);
vec3 col = under * mix(vec3(1.0), vec3(0.5, 0.45, 0.36), damp);
float wet = smoothstep(-0.15, 0.0, h);
col += envReflect(reflect(-v, vec3(0.0, 1.0, 0.0)), 0.15) * fresnel(v.y, 0.03) * wet * 0.8;
float alpha = etch * 0.92;
if (cov > 0.0) {
// what stands in it (dummies, pillars, spikes): the occluder capsules at their foot
float contact = 0.0;
int nOcc = int(uWorldCounts.w);
for (int i = 0; i < ${ MAX_OCCLUDERS } ; i++) {
if (i >= nOcc) break;
vec4 a = worldTexel(3, i * 2), b = worldTexel(3, i * 2 + 1);
float y0 = min(a.y, b.y);
if (y0 - a.w > 0.3) continue;
float d = sdCapsule(vec3(xz.x, max(y0, 0.0), xz.y), a.xyz, b.xyz, a.w);
contact = max(contact, 1.0 - smoothstep(-0.05, 0.35, d));
}
float react = uPoolB.x;
float boil = clamp(contact * 1.3 + 0.3 * smoothstep(0.5, 1.2, ac) - 0.1, 0.0, 1.0) * react;
// simmering surface: slow undulation, choppy where it boils; fades once a pixel spans it
vec3 rq = vec3(xz * 1.1, uTime * 0.3);
vec2 rip = vec2(noise3(rq), noise3(rq + vec3(0.37, 0.61, 0.0))) - 0.5;
g = clamp(g * 3.0, -2.5, 2.5) + rip * (0.08 + 0.9 * boil) * (1.0 - smoothstep(0.004, 0.03, pxw));
vec3 n = normalize(vec3(-g.x, 1.0, -g.y));
float NoV = max(dot(n, v), 1e-3);
float F = fresnel(NoV, 0.025);
vec3 refl = envReflect(reflect(-v, n), 0.05);
vec3 H = normalize(uSunDir + v);
float NoL = max(dot(n, uSunDir), 0.0);
vec3 spec = uSunColor * (PI * spellD_GGX(max(dot(n, H), 0.0), 0.02) * spellV_Smith(NoV, NoL, 0.02) * NoL * fresnel(dot(v, H), 0.025));
vec3 dS, sS;
spellLightPBR(vW, n, v, 0.1, vec3(0.025), vec3(0.0), dS, sS);
// body: the stone seen through the murky liquid (absorbed and clouded over the path down and
// back up: only the thin edges show what is under it)
float behind;
vec3 floorC = sceneRefract(vW, n, v, 1.36, depth * 8.0, behind);
float path = depth * (1.0 + 1.0 / max(NoV, 0.2));
vec3 T = exp(-(uAbsorb + 50.0) * path);
vec3 murk = (uAmbient * 1.2 + uSunColor * max(uSunDir.y, 0.0) * 0.2) * vec3(0.06, 0.075, 0.025) + dS * 0.05;
vec3 body = floorC * T + murk * (1.0 - T);
// its own light: luminous veins drifting through a darker body, brightest where deep and
// where it eats
float fineFlow = (noise3(vec3(xz * 3.4 + sd, uTime * 0.12)) - 0.5) * (1.0 - smoothstep(0.003, 0.012, pxw));
float sw = noise3(vec3(xz * 0.45 + sd, uTime * 0.035)) * 0.6 + noise3(vec3(xz * 1.3 + sd.yx, uTime * 0.06 + 0.5)) * 0.4 + fineFlow * 0.3;
float vein = smoothstep(0.3, 0.8, sw);
float deep = 1.0 - exp(-depth * 110.0);
vec3 emit = mix(uGlowCol, uHotCol, 0.2 + 0.5 * boil) * deep * (0.15 + 0.85 * vein * vein) * (0.4 + 0.6 * react + 0.8 * boil) * 0.7;
vec3 liq = mix(body, refl, F) + spec + sS + emit;
// froth where it reacts (along what stands in it, a little along its eating front), in clumps
float clump = smoothstep(0.38, 0.62, texture(uStoneNoise, xz * 0.6 + sd * 1.3).g);
float foamW = clamp(boil * 1.3 * (0.35 + 0.65 * clump) + smoothstep(0.08, 0.0, h) * 0.3 * react * clump, 0.0, 1.0);
if (foamW > 0.02) {
vec3 nb1, nb2;
float c1 = froth(xz, 0.034, foamW * 0.6, 0.8, nb1);
float c2 = froth(xz + 0.37, 0.012, foamW * 0.9, 1.5, nb2);
// cells smaller than a few pixels fade to their mean (no shimmer): fine froth reads milky
float s1 = smoothstep(1.5, 4.0, 0.034 / pxw), s2 = smoothstep(1.5, 4.0, 0.012 / pxw);
bool one = c1 * s1 > 0.0;
float fc = one ? c1 : max(mix(foamW * 0.3, c1, s1), mix(foamW * 0.45, c2, s2));
float sharp = one ? s1 : s2;
vec3 nf = normalize(mix(vec3(0.0, 1.0, 0.0), one ? nb1 : nb2, sharp * 0.9));
float NoVf = max(dot(nf, v), 0.0);
vec3 rf = reflect(-v, nf);
// big domes are clear (the liquid through a film, glints, a bright rim), small ones milky
float milk = one ? 0.12 : mix(0.75, 0.45, s2);
vec3 milkCol = (uAmbient * 1.5 + uSunColor * max(dot(nf, uSunDir), 0.0) * 0.5) * vec3(0.6, 0.64, 0.48) + uHotCol * (0.15 + 0.4 * boil);
float Ff = fresnel(NoVf, 0.03);
vec3 foamCol = mix(liq * 0.9 + uHotCol * 0.06, milkCol, milk) * (1.0 - Ff) + envReflect(rf, 0.04) * Ff
+ uSunColor * pow(max(dot(rf, uSunDir), 0.0), 500.0) * 8.0 * sharp
+ uHotCol * 0.35 * pow(1.0 - NoVf, 3.0) * sharp;
liq = mix(liq, foamCol, fc);
}
col = mix(col, liq, cov);
alpha = max(alpha, cov);
}
fragColor = vec4(col, alpha);
} `
;
const
CLOUD_GLSL
=
`
uniform vec4 uCloud; // glow, age s, density 0..1, seed
uniform vec4 uCloudShape; // slump 0..1, -, -, -
uniform vec3 uCloudGlow; // linear glow colour
uniform vec3 uCloudAlb; // gas albedo, linear (pale yellow-green)
void volumeSample(vec3 pw, vec3 pl, out float sigma, out vec3 albedo, out vec3 emission) {
float age = uCloud.y, rr = length(pl.xz), slump = uCloudShape.x;
// slow roll about the vertical (faster inside); the gas pattern drifts down (heavy)
float ang = age * (0.12 + 0.2 * (1.0 - rr)), ca = cos(ang), sa = sin(ang);
vec3 q = vec3(ca * pl.x - sa * pl.z, pl.y, sa * pl.x + ca * pl.z) * uVolScale;
q.y += age * 0.16;
q = q * 0.3 + uCloud.w;
// two taps per sample: the coarse one's worley, the fine one's fbm
vec4 nc = noise3v(q), nv = noise3v(q * 2.3 + vec3(0.37, age * 0.02, 0.0));
float n = nc.r * 0.7 + nv.r * 0.3;
// a domed top; a belly that sags and hangs lobes as the heavy gas slumps
float body = 1.0 - length(pl * vec3(1.0, pl.y > 0.0 ? 1.15 + 0.45 * slump : 0.9 - 0.15 * slump, 1.0));
float lobes = (1.0 - smoothstep(-0.6, 0.1, pl.y)) * (nc.g - 0.5) * 0.9;
float d = body + (n - 0.5) * 1.2 + (nv.g - 0.5) * 0.35 + lobes;
// faded well inside the bounding sphere, so the noise never shows its clipped silhouette
sigma = smoothstep(0.0, 0.3, d) * 1.5 * uCloud.z * smoothstep(1.0, 0.55, length(pl));
albedo = uCloudAlb;
// glowing droplet pockets drifting in the core, breathing; their light fills the gas round them
float core = smoothstep(0.12, 0.7, d);
float pocket = smoothstep(0.52, 0.85, nv.r) * 4.0;
float pulse = 0.6 + 0.4 * sin(age * 1.7 + n * 11.0);
emission = uCloudGlow * uCloud.x * (core * core * (0.01 + 0.2 * pocket) * pulse) * sigma;
} `
;
const
SPL
=
{
x
:
0
,
z
:
0
,
radius
:
1
,
acid
:
0
,
pattern
:
'noise'
,
seed
:
0
}
;
const
clamp01
=
(
x
)
=>
(
<
0
?
0
:
>
1
?
1
:
)
;
const
sstep
=
(
a, b, x
)
=>
{
const
=
clamp01
(
(
-
)
/
(
-
)
)
;
return
*
*
(
3
-
2
*
)
;
}
;
export
default
{
id
:
'acid'
,
name
:
'Acid'
,
key
:
'9'
,
hue
:
'#8aff3c'
,
shape
:
'projectile'
,
forms
:
[
'Toxic Bloom'
,
'Corrosion Cloud'
]
,
radius
:
0.3
,
lob
:
4
,
params
:
{
size
:
1
,
speed
:
10
,
glow
:
1
,
drips
:
1
,
fog
:
1
,
bubbles
:
1
,
iridescence
:
0.35
,
corrosion
:
1
,
cloudTime
:
8
,
color
:
'#7cff2a'
,
fogColor
:
'#bfd895'
,
cloudColor
:
'#bfe08a'
}
,
ranges
:
{
size
:
[
0.4
,
2.5
,
0.01
]
,
speed
:
[
4
,
30
,
0.1
]
,
glow
:
[
0
,
3
,
0.01
]
,
drips
:
[
0
,
3
,
0.01
]
,
fog
:
[
0
,
2
,
0.01
]
,
bubbles
:
[
0
,
3
,
0.01
]
,
iridescence
:
[
0
,
1
,
0.01
]
,
corrosion
:
[
0
,
2
,
0.01
]
,
cloudTime
:
[
3
,
15
,
0.1
]
,
}
,
presets
:
{
bile
:
{
color
:
'#d8ff3a'
,
fogColor
:
'#dcd8a0'
,
cloudColor
:
'#e0eb86'
,
glow
:
0.85
}
,
venom
:
{
color
:
'#c24dff'
,
fogColor
:
'#d2c0dc'
,
cloudColor
:
'#b98ad8'
,
bubbles
:
1.6
}
,
radioactive
:
{
color
:
'#a0ff00'
,
fogColor
:
'#c8e2a8'
,
cloudColor
:
'#b0f070'
,
glow
:
2.2
,
fog
:
0.7
,
iridescence
:
0.15
}
,
}
,
timing
:
{
charge
:
0.6
,
impact
:
0.3
,
linger
:
6
}
,
kinds
:
{
drip
:
{
style
:
'glow'
,
drag
:
0.25
,
gravity
:
9.8
,
restitution
:
0.45
,
friction
:
0.6
,
life
:
[
1.4
,
2.2
]
,
size
:
[
0.018
,
0.012
]
,
stretch
:
0.014
,
emissive
:
1.0
,
color
:
[
'#c8ff70'
,
'#3c8a10'
]
,
alpha
:
[
1
,
0.85
]
,
fadeIn
:
0.02
,
fadeOut
:
0.1
,
paints
:
'acid'
,
paintAmount
:
0.25
,
morph
:
'acid.sizzle'
,
forceResponse
:
0.2
}
,
sizzle
:
{
style
:
'glow'
,
drag
:
1.2
,
gravity
:
6
,
life
:
[
0.12
,
0.35
]
,
size
:
[
0.011
,
0.004
]
,
stretch
:
0.012
,
emissive
:
5
,
color
:
[
'#f6ffd0'
,
'#7cff2a'
]
,
alpha
:
[
1
,
0
]
,
fadeIn
:
0.01
,
fadeOut
:
0.4
,
restitution
:
-
1
,
paints
:
'acid'
,
paintAmount
:
0.18
}
,
fog
:
{
style
:
'media'
,
drag
:
0.9
,
buoyancy
:
-
2.2
,
curl
:
0.9
,
curlScale
:
0.14
,
life
:
[
2.8
,
4.8
]
,
size
:
[
0.32
,
0.95
]
,
sizePow
:
0.5
,
emissive
:
0
,
color
:
[
'#bfd895'
,
'#7a8a5a'
]
,
alpha
:
[
0.22
,
0
]
,
fadeIn
:
0.12
,
fadeOut
:
0.5
,
density
:
0.8
,
erosion
:
0.85
,
restitution
:
0
,
friction
:
0.03
,
lightResponse
:
0.8
,
forceResponse
:
0.8
}
,
miasma
:
{
style
:
'media'
,
drag
:
1.1
,
buoyancy
:
-
1.6
,
curl
:
1.2
,
curlScale
:
0.18
,
life
:
[
2.5
,
4.5
]
,
size
:
[
0.35
,
0.9
]
,
sizePow
:
0.6
,
emissive
:
0
,
color
:
[
'#b4c88a'
,
'#6f7d50'
]
,
alpha
:
[
0.35
,
0
]
,
fadeIn
:
0.15
,
fadeOut
:
0.4
,
density
:
1.6
,
erosion
:
0.75
,
restitution
:
0
,
friction
:
0.05
,
forceResponse
:
0.8
,
lightResponse
:
0.8
}
,
fume
:
{
style
:
'media'
,
drag
:
1.4
,
buoyancy
:
0.55
,
curl
:
1.2
,
curlScale
:
0.3
,
life
:
[
1.4
,
2.8
]
,
size
:
[
0.12
,
0.85
]
,
sizePow
:
0.7
,
emissive
:
0
,
color
:
[
'#eef2e2'
,
'#b9c2a8'
]
,
alpha
:
[
0.3
,
0
]
,
fadeIn
:
0.15
,
density
:
1.6
,
erosion
:
0.6
,
lightResponse
:
0.9
}
,
bead
:
{
style
:
'glow'
,
drag
:
1.5
,
life
:
[
0.4
,
0.8
]
,
size
:
[
0.013
,
0.006
]
,
stretch
:
0.01
,
emissive
:
3
,
color
:
[
'#e8ffa8'
,
'#7cff2a'
]
,
alpha
:
[
0.2
,
1
]
,
fadeIn
:
0.3
,
fadeOut
:
0.1
,
restitution
:
-
1
}
,
}
,
create
(
fx
)
{
const
S
=
this
,
P
=
.
particles
,
Q
=
.
Q
;
const
=
P
.
emitter
(
'acid.drip'
,
{
shape
:
'sphere'
,
radius
:
0.22
,
spread
:
0.3
}
)
;
const
=
P
.
emitter
(
'acid.drip'
,
{
shape
:
'sphere'
,
radius
:
0.3
,
spread
:
1.5
,
radial
:
3.2
}
)
;
const
=
P
.
emitter
(
'acid.drip'
,
{
shape
:
'disk'
,
radius
:
2
,
spread
:
0.15
}
)
;
const
=
P
.
emitter
(
'acid.drip'
,
{
shape
:
'ring'
,
radius
:
0.3
,
spread
:
0.05
}
)
;
const
=
P
.
emitter
(
'acid.sizzle'
,
{
shape
:
'disk'
,
radius
:
1.6
,
spread
:
1.2
}
)
;
const
=
P
.
emitter
(
'acid.sizzle'
,
{
shape
:
'ring'
,
radius
:
0.36
,
spread
:
0.9
}
)
;
const
=
P
.
emitter
(
'acid.sizzle'
,
{
shape
:
'sphere'
,
radius
:
0.02
,
spread
:
0.7
}
)
;
const
=
P
.
emitter
(
'acid.bead'
,
{
shape
:
'shell'
,
radius
:
1.1
,
spread
:
0.15
,
radial
:
-
2.2
}
)
;
const
=
P
.
emitter
(
'acid.fog'
,
{
shape
:
'disk'
,
radius
:
0.6
,
spread
:
0.6
,
radial
:
3.6
}
)
;
const
=
P
.
emitter
(
'acid.miasma'
,
{
shape
:
'disk'
,
radius
:
0.8
,
spread
:
0.5
,
radial
:
2.4
}
)
;
const
=
P
.
emitter
(
'acid.fume'
,
{
shape
:
'sphere'
,
radius
:
0.25
,
spread
:
0.4
,
size
:
0.7
,
life
:
0.6
}
)
;
const
=
P
.
emitter
(
'acid.fume'
,
{
shape
:
'ring'
,
radius
:
0.32
,
spread
:
0.25
}
)
;
const
=
P
.
emitter
(
'acid.fume'
,
{
shape
:
'sphere'
,
radius
:
0.02
,
spread
:
0.15
,
size
:
0.35
,
life
:
0.6
}
)
;
const
=
P
.
emitter
(
'acid.fog'
,
{
shape
:
'sphere'
,
radius
:
2.2
,
spread
:
0.3
,
life
:
0.6
}
)
;
const
=
P
.
emitter
(
'acid.fog'
,
{
shape
:
'disk'
,
radius
:
1.8
,
spread
:
0.3
}
)
;
const
=
P
.
emitter
(
'acid.miasma'
,
{
shape
:
'sphere'
,
radius
:
1.6
,
spread
:
0.3
}
)
;
P
.
fieldEmitter
(
'acid.fume'
,
{
slots
:
768
,
b
:
[
0
,
1
,
0
,
0
]
,
threshold
:
0.35
,
rate
:
5
,
up
:
0.25
}
)
;
P
.
fieldEmitter
(
'acid.sizzle'
,
{
slots
:
256
,
b
:
[
0
,
1
,
0
,
0
]
,
threshold
:
0.6
,
rate
:
8
,
up
:
1.1
}
)
;
const
=
new
THREE. InstancedBufferGeometry
(
)
;
.
setAttribute
(
'position'
,
new
THREE. Float32BufferAttribute
(
[
-
1
,
-
1
,
0
,
1
,
-
1
,
0
,
1
,
1
,
0
,
-
1
,
1
,
0
]
,
3
)
)
;
.
setIndex
(
[
0
,
1
,
2
,
0
,
2
,
3
]
)
;
const
attr
=
(
name
)
=>
{
const
=
new
THREE. InstancedBufferAttribute
(
new
Float32Array
(
N_BUB
*
4
)
,
4
)
;
.
setUsage
(
THREE
.
DynamicDrawUsage
)
;
.
setAttribute
(
,
)
;
return
;
}
;
const
A0
=
attr
(
'aB0'
)
,
A1
=
attr
(
'aB1'
)
,
A2
=
attr
(
'aB2'
)
;
const
B0
=
A0
.
array
,
B1
=
A1
.
array
,
B2
=
A2
.
array
;
.
instanceCount
=
0
;
const
=
{
uNow
:
{
value
:
0
}
,
uTint
:
{
value
:
new
THREE. Color
(
)
}
,
uHot
:
{
value
:
new
THREE. Color
(
)
}
,
uIri
:
{
value
:
new
THREE. Vector2
(
1
,
0.35
)
}
}
;
const
=
new
THREE. Mesh
(
,
new
THREE. RawShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
vertexShader
:
BUBBLE_VERT
,
fragmentShader
:
BUBBLE_FRAG
,
uniforms
:
{
...
.
U
,
...
}
,
...
FX_BLENDING
,
}
)
)
;
.
frustumCulled
=
false
;
.
visible
=
false
;
.
scenes
.
fx
.
add
(
)
;
let
=
0
,
=
0
,
=
-
1
,
=
false
;
function
spawnBubble
(
x, z, r, life, delay, drift
)
{
const
=
++
%
N_BUB
,
=
*
4
,
=
.
rand
(
)
*
6.2832
;
B0
[
]
=
;
B0
[
+
1
]
=
SURF
;
B0
[
+
2
]
=
;
B0
[
+
3
]
=
+
;
B1
[
]
=
;
B1
[
+
1
]
=
;
B1
[
+
2
]
=
0
;
B1
[
+
3
]
=
.
rand
(
)
;
B2
[
]
=
Math
.
cos
(
)
*
;
B2
[
+
1
]
=
Math
.
sin
(
)
*
;
B2
[
+
2
]
=
*
(
0.1
+
0.3
*
.
rand
(
)
)
;
B2
[
+
3
]
=
2
+
4
*
.
rand
(
)
;
=
Math
.
max
(
,
+
+
+
POP
)
;
=
true
;
}
function
bubbleAt
(
i, tau, out
)
{
const
=
*
4
,
=
B1
[
+
3
]
*
6.2832
;
return
.
set
(
B0
[
]
+
B2
[
]
*
+
B2
[
+
2
]
*
Math
.
sin
(
B2
[
+
3
]
*
+
)
,
B0
[
+
1
]
,
B0
[
+
2
]
+
B2
[
+
1
]
*
+
B2
[
+
2
]
*
Math
.
cos
(
B2
[
+
3
]
*
0.83
*
+
B1
[
+
3
]
*
11
)
)
;
}
function
froth
(
x, z, spread, n, big, delay
)
{
*=
Q
.
emission
*
Q
.
auto
.
emission
;
=
Math
.
floor
(
+
.
rand
(
)
)
;
for
(
let
=
0
;
<
;
++
)
{
const
=
.
rand
(
)
*
6.2832
,
=
Math
.
sqrt
(
.
rand
(
)
)
*
,
=
.
rand
(
)
;
const
=
.
rand
(
)
<
;
const
=
?
0.02
+
0.035
*
.
rand
(
)
:
0.004
+
0.016
*
*
;
const
=
?
0.25
+
0.4
*
.
rand
(
)
:
0.4
+
1.5
*
.
rand
(
)
;
spawnBubble
(
+
Math
.
cos
(
)
*
,
+
Math
.
sin
(
)
*
,
,
,
*
.
rand
(
)
,
0.005
+
0.025
*
.
rand
(
)
)
;
}
}
const
=
new
THREE. PlaneGeometry
(
2
,
2
)
.
rotateX
(
-
Math
.
PI
/
2
)
;
const
=
[
]
;
for
(
let
=
0
;
<
MAX_POOLS
;
++
)
{
const
=
{
uPoolA
:
{
value
:
new
THREE. Vector4
(
)
}
,
uPoolB
:
{
value
:
new
THREE. Vector4
(
)
}
,
uGlowCol
:
{
value
:
new
THREE. Color
(
)
}
,
uHotCol
:
{
value
:
new
THREE. Color
(
)
}
,
uAbsorb
:
{
value
:
new
THREE. Color
(
)
}
,
}
;
const
=
new
THREE. Mesh
(
,
new
THREE. ShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
vertexShader
:
POOL_VERT
,
fragmentShader
:
POOL_FRAG
,
uniforms
:
{
...
.
U
,
uStoneNoise
:
.
uStoneNoise
,
...
}
,
transparent
:
true
,
depthWrite
:
false
,
blending
:
THREE
.
NormalBlending
,
}
)
)
;
.
visible
=
false
;
.
renderOrder
=
-
1
;
.
scenes
.
refract
.
add
(
)
;
.
push
(
{
mesh
:
,
,
busy
:
false
}
)
;
}
function
poolAcquire
(
x, z, R , seed
)
{
for
(
const
of
)
if
(
!
.
busy
)
{
.
busy
=
true
;
.
mesh
.
visible
=
true
;
.
mesh
.
position
.
set
(
,
0.005
,
)
;
.
mesh
.
scale
.
set
(
R
,
1
,
R
)
;
.
u
.
uPoolA
.
value
.
set
(
,
,
R
,
0
)
;
.
u
.
uPoolB
.
value
.
set
(
0
,
0
,
0
,
(
%
97
)
*
0.0731
)
;
return
;
}
return
null
;
}
function
poolRelease
(
pl
)
{
if
(
)
{
.
busy
=
false
;
.
mesh
.
visible
=
false
;
}
}
function
poolStyle
(
pl, p, liquid, react
)
{
const
=
.
u
;
.
uPoolA
.
value
.
w
=
;
.
uPoolB
.
value
.
x
=
;
.
uPoolB
.
value
.
z
=
.
corrosion
;
.
uGlowCol
.
value
.
copy
(
)
.
multiplyScalar
(
1.1
*
.
glow
)
;
.
uHotCol
.
value
.
copy
(
)
.
multiplyScalar
(
1.4
*
.
glow
)
;
const
=
;
.
uAbsorb
.
value
.
setRGB
(
6
+
30
*
(
1
-
.
r
)
**
1.5
,
6
+
30
*
(
1
-
.
g
)
**
1.5
,
6
+
30
*
(
1
-
.
b
)
**
1.5
)
;
}
const
=
FluidVolume
.
get
(
)
;
const
=
new
THREE. Mesh
(
,
.
domains
[
0
]
.
material
)
;
.
visible
=
false
;
.
frustumCulled
=
false
;
.
scenes
.
fx
.
add
(
)
;
const
SRC
=
{
pos
:
new
THREE. Vector3
(
)
,
vel
:
new
THREE. Vector3
(
)
,
radius
:
1
,
fuel
:
0
,
temp
:
0
,
soot
:
0
,
radial
:
0
,
noise
:
0
,
noiseScale
:
1
,
seed
:
0
,
coupling
:
0
,
burst
:
false
}
;
function
gasSrc
(
f, x, y, z, radius, soot, temp, burst, noise, noiseScale, seed, vx, vy, vz, radial, coupling
)
{
SRC
.
pos
.
set
(
,
,
)
;
SRC
.
radius
=
;
SRC
.
soot
=
;
SRC
.
temp
=
;
SRC
.
burst
=
;
SRC
.
noise
=
;
SRC
.
noiseScale
=
;
SRC
.
seed
=
;
SRC
.
vel
.
set
(
,
,
)
;
SRC
.
radial
=
;
SRC
.
coupling
=
;
.
emit
(
SRC
)
;
}
const
=
[
]
;
for
(
let
=
0
;
<
2
;
++
)
{
const
=
.
volumes
.
add
(
{
shape
:
'sphere'
,
glsl
:
CLOUD_GLSL
,
maxSteps
:
12
,
uniforms
:
{
uCloud
:
{
value
:
new
THREE. Vector4
(
)
}
,
uCloudShape
:
{
value
:
new
THREE. Vector4
(
)
}
,
uCloudGlow
:
{
value
:
new
THREE. Color
(
)
}
,
uCloudAlb
:
{
value
:
new
THREE. Color
(
)
}
}
,
}
)
;
.
g
=
0.35
;
.
ambient
=
1.1
;
.
sun
=
1.0
;
.
push
(
)
;
}
const
=
Array
.
from
(
{
length
:
16
}
,
(
)
=>
(
{
orb
:
null
,
light
:
null
,
vortex
:
null
,
cloud
:
null
,
gas
:
null
,
pool
:
null
,
blob
:
new
Float32Array
(
8
*
8
)
,
splashT
:
-
1
,
splashFall
:
true
,
nextSplat
:
0
,
froth
:
0
,
}
)
)
;
const
=
new
THREE. Color
(
)
,
=
new
THREE. Vector3
(
)
,
=
new
THREE. Vector3
(
)
;
const
=
new
THREE. Color
(
)
,
=
new
THREE. Color
(
)
,
=
new
THREE. Color
(
1
,
1
,
1
)
,
=
new
THREE. Color
(
1
,
1
,
0.72
)
;
let
=
''
,
=
''
;
const
hex
=
(
c
)
=>
` # ${ c. getHexString ( ) } `
;
function
syncColors
(
)
{
const
=
S
.
params
;
.
set
(
.
color
)
;
.
copy
(
)
.
lerp
(
,
0.45
)
;
if
(
.
color
===
&&
.
fogColor
===
)
return
;
=
.
color
;
=
.
fogColor
;
const
=
hex
(
.
set
(
.
color
)
.
multiplyScalar
(
0.3
)
)
,
=
hex
(
.
set
(
.
color
)
.
lerp
(
,
0.7
)
)
,
=
hex
(
.
set
(
.
color
)
.
lerp
(
,
0.3
)
)
;
P
.
setKind
(
'acid.drip'
,
{
color
:
[
,
]
}
)
;
P
.
setKind
(
'acid.sizzle'
,
{
color
:
[
,
.
color
]
}
)
;
P
.
setKind
(
'acid.bead'
,
{
color
:
[
,
.
color
]
}
)
;
P
.
setKind
(
'acid.miasma'
,
{
color
:
[
hex
(
.
set
(
.
fogColor
)
.
lerp
(
,
0.2
)
)
,
hex
(
.
set
(
.
fogColor
)
.
lerp
(
,
0.2
)
.
multiplyScalar
(
0.55
)
)
]
}
)
;
P
.
setKind
(
'acid.fog'
,
{
color
:
[
.
fogColor
,
hex
(
.
set
(
.
fogColor
)
.
multiplyScalar
(
0.6
)
)
]
}
)
;
P
.
setKind
(
'acid.fume'
,
{
color
:
[
hex
(
.
set
(
.
fogColor
)
.
lerp
(
,
0.7
)
)
,
hex
(
.
set
(
.
fogColor
)
.
lerp
(
,
0.25
)
.
multiplyScalar
(
0.85
)
)
]
}
)
;
}
function
blobAcquire
(
s, p
)
{
.
orb
=
.
metaballs
?.
acquire
(
{
preset
:
'acid'
}
)
??
null
;
if
(
.
orb
)
blobStyle
(
.
orb
,
)
;
}
function
blobStyle
(
h, p
)
{
const
=
;
.
emission
.
copy
(
)
.
lerp
(
,
0.3
)
.
multiplyScalar
(
4.5
*
.
glow
)
;
.
scatterColor
.
copy
(
)
.
multiplyScalar
(
0.05
)
;
.
absorption
.
setRGB
(
2.5
+
25
*
(
1
-
.
r
)
**
2
,
2.5
+
25
*
(
1
-
.
g
)
**
2
,
2.5
+
25
*
(
1
-
.
b
)
**
2
)
;
.
wobble
=
0.03
;
.
turbidity
=
14
;
.
bubbles
=
0.5
;
}
function
blobShape
(
s, pos, R , t, vel, spiral
)
{
const
=
.
orb
;
if
(
!
)
return
;
.
set
(
0
,
.
x
,
.
y
,
.
z
,
R
*
0.3
*
(
1
+
0.07
*
Math
.
sin
(
*
7.3
)
)
)
;
for
(
let
=
1
;
<=
4
;
++
)
{
const
=
*
(
1.9
+
*
0.37
)
+
*
2.4
,
=
*
1.3
+
*
1.7
;
const
=
R
*
(
0.19
+
0.05
*
Math
.
sin
(
*
3.1
+
)
)
+
;
.
set
(
,
.
x
+
*
Math
.
cos
(
)
*
Math
.
cos
(
)
,
.
y
+
*
Math
.
sin
(
)
,
.
z
+
*
Math
.
sin
(
)
*
Math
.
cos
(
)
,
R
*
(
0.15
+
0.04
*
Math
.
sin
(
*
4.7
+
*
2.1
)
)
)
;
}
if
(
!
)
{
.
count
=
5
;
return
;
}
.
copy
(
)
.
normalize
(
)
;
for
(
let
=
0
;
<
2
;
++
)
{
const
=
R
*
(
0.3
+
0.18
*
)
;
.
set
(
5
+
,
.
x
-
.
x
*
,
.
y
-
.
y
*
-
0.03
*
,
.
z
-
.
z
*
,
R
*
(
0.17
-
0.06
*
)
)
;
}
const
=
(
*
1.7
)
%
1
,
=
R
*
(
0.42
+
0.9
*
)
;
.
set
(
7
,
.
x
-
.
x
*
,
.
y
-
.
y
*
-
0.5
*
*
*
R
,
.
z
-
.
z
*
,
R
*
0.1
*
(
1
-
*
)
)
;
.
count
=
8
;
}
function
blobSplash
(
s, pos, size, fall
)
{
const
B
=
.
blob
;
for
(
let
=
0
;
<
8
;
++
)
{
const
=
*
8
,
=
.
rand
(
)
*
6.2832
,
=
===
0
?
0.3
:
(
?
1.2
+
2.4
*
.
rand
(
)
:
2.5
+
2
*
.
rand
(
)
)
;
const
=
===
0
?
-
0.5
:
(
?
0.4
+
1.8
*
.
rand
(
)
:
(
.
rand
(
)
-
0.3
)
*
3
)
;
B
[
]
=
.
x
;
B
[
+
1
]
=
.
y
;
B
[
+
2
]
=
.
z
;
B
[
+
3
]
=
Math
.
cos
(
)
*
;
B
[
+
4
]
=
;
B
[
+
5
]
=
Math
.
sin
(
)
*
;
B
[
+
6
]
=
*
(
===
0
?
0.26
:
0.07
+
0.08
*
.
rand
(
)
)
;
B
[
+
7
]
=
0
;
}
.
splashT
=
0
;
.
splashFall
=
;
if
(
.
orb
)
.
orb
.
bubbles
=
0.15
;
}
function
blobUpdate
(
s, dt, dm
)
{
const
=
.
orb
,
B
=
.
blob
;
.
splashT
+=
;
const
=
.
splashFall
?
1.8
:
0.45
,
=
.
splashT
/
;
if
(
>=
1
||
!
)
{
blobRelease
(
)
;
return
;
}
for
(
let
=
0
;
<
8
;
++
)
{
const
=
*
8
;
if
(
.
splashFall
)
B
[
+
4
]
-=
9.81
*
;
else
{
B
[
+
3
]
*=
0.9
;
B
[
+
4
]
*=
0.9
;
B
[
+
5
]
*=
0.9
;
}
B
[
]
+=
B
[
+
3
]
*
;
B
[
+
1
]
+=
B
[
+
4
]
*
;
B
[
+
2
]
+=
B
[
+
5
]
*
;
const
=
.
splashFall
?
B
[
+
6
]
*
(
1
-
sstep
(
0.3
,
1
,
)
)
**
0.7
:
B
[
+
6
]
*
(
1
-
)
**
0.6
;
if
(
.
splashFall
&&
)
{
const
=
B
[
]
-
.
pos
.
x
,
=
B
[
+
2
]
-
.
pos
.
z
,
=
Math
.
hypot
(
,
)
,
=
0.3
+
*
0.35
;
if
(
<
&&
B
[
+
1
]
>
0.25
&&
B
[
+
1
]
<
1.75
)
{
const
=
/
Math
.
max
(
,
1e-3
)
;
B
[
]
=
.
pos
.
x
+
*
;
B
[
+
2
]
=
.
pos
.
z
+
*
;
B
[
+
3
]
=
0
;
B
[
+
5
]
=
0
;
B
[
+
4
]
=
Math
.
max
(
B
[
+
4
]
,
-
0.35
)
;
}
}
const
=
-
0.45
*
;
if
(
.
splashFall
&&
B
[
+
1
]
<
)
{
B
[
+
1
]
=
;
B
[
+
4
]
=
0
;
const
=
Math
.
exp
(
-
*
6
)
;
B
[
+
3
]
*=
;
B
[
+
5
]
*=
;
}
.
set
(
,
B
[
]
,
B
[
+
1
]
,
B
[
+
2
]
,
)
;
}
.
count
=
8
;
}
function
blobRelease
(
s
)
{
.
orb
?.
release
(
)
;
.
orb
=
null
;
.
splashT
=
-
1
;
}
function
dissolveNear
(
x, z, R , base, add
)
{
for
(
const
of
.
dummies
)
{
const
=
Math
.
hypot
(
.
pos
.
x
-
,
.
pos
.
z
-
)
;
if
(
<
R
)
{
.
status
.
dissolve
=
Math
.
max
(
.
status
.
dissolve
,
*
(
1
-
/
R
)
+
)
;
.
hit
(
.
set
(
.
pos
.
x
-
,
0
,
.
pos
.
z
-
)
,
0.35
*
(
1
-
/
R
)
)
;
}
}
}
function
eatDummy
(
dm, k, dt
)
{
const
=
S
.
params
;
const
=
Math
.
floor
(
.
rand
(
)
*
6
)
,
=
.
pos
.
x
*
1.7
+
.
pos
.
z
*
2.3
+
*
2.1
;
if
(
<
4
)
.
pos
.
set
(
.
pos
.
x
+
Math
.
cos
(
)
*
0.27
,
0.78
,
.
pos
.
z
+
Math
.
sin
(
)
*
0.22
)
;
else
.
pos
.
set
(
.
pos
.
x
+
(
===
4
?
-
0.58
:
0.58
)
,
1.22
,
.
pos
.
z
)
;
.
radius
=
0.01
;
.
vel
.
set
(
0
,
-
0.1
,
0
)
;
.
rate
(
14
*
*
.
drips
,
)
;
.
pos
.
set
(
.
pos
.
x
,
0.15
+
1.3
*
.
rand
(
)
,
.
pos
.
z
)
;
.
radius
=
0.32
;
.
vel
.
set
(
0
,
0.25
,
0
)
;
.
size
=
0.7
;
.
rate
(
45
*
*
.
fog
,
)
;
.
pos
.
set
(
.
pos
.
x
,
0.03
,
.
pos
.
z
)
;
.
radius
=
0.38
;
.
vel
.
set
(
0
,
1.4
,
0
)
;
.
rate
(
90
*
*
.
glow
,
)
;
}
return
{
onParam
(
k
)
{
if
(
===
'color'
||
===
'fogColor'
)
syncColors
(
)
;
}
,
phase
(
c, name
)
{
const
=
S
.
params
,
=
[
.
index
]
,
=
.
size
,
=
.
form
===
'Corrosion Cloud'
;
if
(
===
'charge'
)
{
syncColors
(
)
;
.
splashT
=
-
1
;
.
nextSplat
=
0
;
.
froth
=
0
;
.
cloud
=
null
;
.
gas
=
null
;
.
vortex
=
null
;
.
pool
=
null
;
.
durations
.
linger
=
?
.
cloudTime
:
S
.
timing
.
linger
;
blobAcquire
(
,
)
;
.
light
=
.
lights
.
acquire
(
)
;
if
(
.
light
)
{
.
light
.
range
=
7
;
.
light
.
intensity
=
0
;
.
light
.
color
.
copy
(
)
;
.
light
.
shadow
=
true
;
}
}
else
if
(
===
'release'
)
{
.
rig
.
shake
(
0.08
,
9
)
;
}
else
if
(
===
'travel'
)
{
const
D
=
Math
.
hypot
(
.
to
.
x
-
.
pos
.
x
,
.
to
.
z
-
.
pos
.
z
)
,
T
=
Math
.
max
(
0.35
,
D
/
Math
.
max
(
.
speed
,
1
)
)
;
.
vel
.
subVectors
(
.
to
,
.
pos
)
.
multiplyScalar
(
1
/
T
)
;
.
vel
.
y
+=
0.5
*
9.81
*
T
;
}
else
if
(
===
'impact'
)
{
if
(
.
orb
)
blobSplash
(
,
.
pos
,
,
!
)
;
if
(
)
bloomCloud
(
,
,
)
;
else
bloom
(
,
,
)
;
}
else
if
(
===
'done'
)
{
blobRelease
(
)
;
.
light
?.
release
(
)
;
.
light
=
null
;
.
vortex
?.
release
(
)
;
.
vortex
=
null
;
if
(
.
cloud
)
.
cloud
.
visible
=
false
;
.
cloud
=
null
;
.
gas
?.
release
(
)
;
.
gas
=
null
;
poolRelease
(
.
pool
)
;
.
pool
=
null
;
}
}
,
update
(
c, dt
)
{
const
=
S
.
params
,
=
[
.
index
]
,
L
=
.
light
,
=
.
size
,
=
.
form
===
'Corrosion Cloud'
;
const
=
0.85
+
0.15
*
Math
.
sin
(
.
age
*
23
+
.
seed
)
*
Math
.
sin
(
.
age
*
9.1
)
;
if
(
.
phase
===
'charge'
)
{
const
=
.
t
/
.
durations
.
charge
;
if
(
.
orb
)
{
blobStyle
(
.
orb
,
)
;
blobShape
(
,
.
pos
,
*
(
0.15
+
0.85
*
(
1
-
(
1
-
)
**
2
)
)
,
.
age
,
null
,
(
1
-
)
*
0.5
*
)
;
}
.
pos
.
copy
(
.
pos
)
;
.
rate
(
260
*
*
.
glow
,
)
;
.
pos
.
copy
(
.
pos
)
;
.
vel
.
set
(
0
,
0
,
0
)
;
.
radius
=
0.3
*
;
.
size
=
0.5
*
;
.
rate
(
20
*
*
.
fog
,
)
;
if
(
L
)
{
L
.
pos
.
copy
(
.
pos
)
;
L
.
intensity
=
6
*
*
*
.
glow
;
}
}
else
if
(
.
phase
===
'travel'
)
{
blobShape
(
,
.
pos
,
,
.
age
,
.
vel
,
0
)
;
.
pos
.
copy
(
.
pos
)
;
.
vel
.
copy
(
.
vel
)
.
multiplyScalar
(
0.25
)
;
.
radius
=
0.22
*
;
.
rate
(
110
*
.
drips
,
)
;
.
pos
.
copy
(
.
pos
)
;
.
vel
.
copy
(
.
vel
)
.
multiplyScalar
(
0.1
)
;
.
radius
=
0.25
*
;
.
size
=
0.7
*
;
.
rate
(
60
*
.
fog
,
)
;
if
(
L
)
{
L
.
pos
.
copy
(
.
pos
)
;
L
.
intensity
=
9
*
*
.
glow
;
}
}
else
{
if
(
.
splashT
>=
0
)
blobUpdate
(
,
,
.
target
>=
0
?
.
dummies
[
.
target
]
:
null
)
;
if
(
)
updateCloud
(
,
,
,
,
)
;
else
updatePool
(
,
,
,
,
)
;
}
}
,
tick
(
dt
)
{
const
=
;
+=
;
if
(
<
-
0.5
)
{
.
visible
=
false
;
return
;
}
.
visible
=
true
;
.
instanceCount
=
N_BUB
;
.
uNow
.
value
=
;
.
uIri
.
value
.
set
(
1
,
S
.
params
.
iridescence
)
;
.
uTint
.
value
.
copy
(
)
.
multiplyScalar
(
0.35
*
S
.
params
.
glow
)
;
.
uHot
.
value
.
copy
(
)
.
multiplyScalar
(
S
.
params
.
glow
)
;
if
(
)
{
A0
.
needsUpdate
=
A1
.
needsUpdate
=
A2
.
needsUpdate
=
true
;
=
false
;
}
let
=
0
;
for
(
let
=
0
;
<
N_BUB
&&
<
4
;
++
)
{
const
=
*
4
,
=
B1
[
+
1
]
,
=
-
B0
[
+
3
]
;
if
(
<=
0
||
<
||
-
B0
[
+
3
]
>=
)
continue
;
const
=
B1
[
]
;
if
(
<
0.006
&&
.
rand
(
)
<
0.7
)
continue
;
bubbleAt
(
,
,
.
pos
)
;
.
radius
=
;
.
vel
.
set
(
0
,
0.8
+
30
*
,
0
)
;
.
burst
(
1
+
*
140
)
;
if
(
>
0.014
)
{
.
pos
.
copy
(
.
pos
)
;
.
size
=
0.25
+
6
*
;
.
burst
(
1
)
;
}
++
;
}
}
,
}
;
function
bloom
(
c, p, s
)
{
const
=
.
pos
,
=
.
size
;
const
R
=
2.6
*
;
.
pos
.
copy
(
)
;
.
vel
.
set
(
0
,
1.2
,
0
)
;
.
radius
=
0.3
*
;
.
burst
(
180
*
.
drips
)
;
.
pos
.
copy
(
)
.
setY
(
0.05
)
;
.
radius
=
0.9
*
;
.
vel
.
set
(
0
,
1.6
,
0
)
;
.
burst
(
160
*
.
glow
)
;
.
pos
.
copy
(
)
.
setY
(
0.25
)
;
.
radius
=
0.8
*
;
.
radial
=
4.2
*
;
.
size
=
;
.
burst
(
150
*
.
fog
)
;
.
pos
.
copy
(
)
.
setY
(
0.4
)
;
.
vel
.
set
(
0
,
0.8
,
0
)
;
.
radius
=
0.5
*
;
.
size
=
1.2
*
;
.
burst
(
50
*
.
fog
)
;
.
pos
.
copy
(
)
.
setY
(
0.2
)
;
.
radius
=
0.7
*
;
.
size
=
0.8
*
;
.
burst
(
30
*
.
fog
)
;
SPL
.
x
=
.
x
;
SPL
.
z
=
.
z
;
SPL
.
pattern
=
'noise'
;
SPL
.
radius
=
1.4
*
;
SPL
.
acid
=
0.85
*
.
corrosion
;
SPL
.
seed
=
.
seed
%
97
;
.
ground
.
splat
(
SPL
)
;
SPL
.
pattern
=
'radial'
;
SPL
.
radius
=
0.7
*
;
SPL
.
acid
=
0.6
*
.
corrosion
;
SPL
.
seed
=
.
seed
%
89
;
.
ground
.
splat
(
SPL
)
;
.
shocks
?.
spawn
(
{
pos
:
.
copy
(
)
.
setY
(
0.05
)
,
radius0
:
0.3
,
radius1
:
3.2
*
,
duration
:
0.45
,
thickness
:
0.5
,
distortion
:
0.025
,
ground
:
true
,
intensity
:
0
}
)
;
.
pool
=
poolAcquire
(
.
x
,
.
z
,
3.4
*
,
.
seed
)
;
for
(
let
=
0
;
<
14
;
++
)
{
const
=
.
rand
(
)
*
6.2832
,
=
0.3
+
1.2
*
Math
.
sqrt
(
.
rand
(
)
)
*
;
froth
(
.
x
+
Math
.
cos
(
)
*
,
.
z
+
Math
.
sin
(
)
*
,
0.12
,
9
*
.
bubbles
,
0.12
,
0.5
)
;
}
dissolveNear
(
.
x
,
.
z
,
R
,
0.45
*
.
corrosion
,
0.2
*
.
corrosion
)
;
if
(
.
target
>=
0
)
{
const
=
.
dummies
[
.
target
]
;
.
status
.
dissolve
=
Math
.
max
(
.
status
.
dissolve
,
0.6
*
.
corrosion
)
;
}
if
(
.
light
)
{
.
light
.
intensity
=
12
*
.
glow
;
.
light
.
range
=
9
*
;
.
light
.
pos
.
copy
(
)
.
setY
(
Math
.
max
(
.
y
,
0.5
)
)
;
}
.
flash
(
0.06
*
.
glow
)
;
.
rig
.
shake
(
0.25
,
14
)
;
if
(
!
.
reduced
)
.
rig
.
punch
(
1.2
,
0.06
)
;
.
nextSplat
=
0.1
;
}
function
updatePool
(
c, p, s, dt, flick
)
{
const
=
.
size
,
=
.
pos
;
const
T
=
.
phase
===
'impact'
?
.
t
:
.
durations
.
impact
+
.
t
;
const
=
.
durations
.
impact
+
.
durations
.
linger
-
T
;
const
=
clamp01
(
/
2.5
)
,
=
(
0.25
+
0.75
*
Math
.
exp
(
-
T
/
2.2
)
)
*
;
if
(
.
pool
)
poolStyle
(
.
pool
,
,
sstep
(
0
,
0.35
,
T
)
*
(
0.35
+
0.65
*
)
,
)
;
.
nextSplat
-=
;
if
(
T
<
1.3
&&
.
nextSplat
<=
0
)
{
.
nextSplat
=
0.12
;
SPL
.
x
=
.
x
;
SPL
.
z
=
.
z
;
SPL
.
pattern
=
'noise'
;
SPL
.
radius
=
(
1.4
+
1.3
*
T
)
*
;
SPL
.
acid
=
0.13
*
.
corrosion
;
SPL
.
seed
=
(
.
seed
+
T
*
37
)
%
97
;
.
ground
.
splat
(
SPL
)
;
}
if
(
T
<
1.6
)
{
const
=
1
-
T
/
1.6
;
.
pos
.
copy
(
)
.
setY
(
0.25
)
;
.
radius
=
1.0
*
;
.
radial
=
2.4
*
;
.
size
=
;
.
rate
(
240
*
.
fog
*
,
)
;
}
.
pos
.
copy
(
)
.
setY
(
0.15
)
;
.
radius
=
1.4
*
;
.
radial
=
0.9
*
;
.
size
=
0.8
*
;
.
rate
(
30
*
.
fog
*
,
)
;
.
pos
.
copy
(
)
.
setY
(
0.05
)
;
.
vel
.
set
(
0
,
0.4
,
0
)
;
.
radius
=
1.1
*
;
.
size
=
0.9
*
;
.
rate
(
30
*
.
fog
*
,
)
;
.
froth
+=
34
*
*
.
bubbles
*
;
while
(
.
froth
>=
1
)
{
.
froth
-=
1
;
let
,
;
const
=
.
target
>=
0
?
.
dummies
[
.
target
]
:
null
;
if
(
&&
.
rand
(
)
<
0.55
&&
Math
.
hypot
(
.
pos
.
x
-
.
x
,
.
pos
.
z
-
.
z
)
<
2
*
)
{
const
=
.
rand
(
)
*
6.2832
,
=
0.36
+
0.12
*
.
rand
(
)
;
=
.
pos
.
x
+
Math
.
cos
(
)
*
;
=
.
pos
.
z
+
Math
.
sin
(
)
*
;
}
else
{
const
=
.
rand
(
)
*
6.2832
,
=
1.5
*
*
Math
.
sqrt
(
.
rand
(
)
)
;
=
.
x
+
Math
.
cos
(
)
*
;
=
.
z
+
Math
.
sin
(
)
*
;
}
froth
(
,
,
0.08
,
6
,
0.08
,
0.05
)
;
}
for
(
const
of
.
dummies
)
{
if
(
Math
.
hypot
(
.
pos
.
x
-
.
x
,
.
pos
.
z
-
.
z
)
>
1.8
*
)
continue
;
if
(
.
phase
===
'linger'
&&
>
1
)
.
status
.
dissolve
=
Math
.
min
(
0.85
,
.
status
.
dissolve
+
(
0.08
+
0.05
*
.
corrosion
)
*
)
;
eatDummy
(
,
,
)
;
}
if
(
.
light
)
{
const
=
4.5
*
*
.
glow
*
(
0.4
+
0.6
*
)
*
Math
.
min
(
1
,
/
2
)
;
.
light
.
intensity
=
Math
.
max
(
.
light
.
intensity
*
Math
.
exp
(
-
/
0.25
)
,
)
;
.
light
.
pos
.
y
+=
(
0.6
-
.
light
.
pos
.
y
)
*
Math
.
min
(
1
,
*
4
)
;
}
}
function
bloomCloud
(
c, p, s
)
{
const
=
.
size
,
=
.
to
;
.
cloud
=
null
;
const
=
.
gas
=
.
acquire
(
{
size
:
[
15
*
,
3
*
,
15
*
]
,
res
:
Math
.
round
(
.
res
*
1.3
)
}
)
;
if
(
)
{
.
position
.
set
(
.
x
,
0.5
*
.
size
.
y
-
.
h
,
.
z
)
;
Object
.
assign
(
,
{
ignition
:
10
,
burnRate
:
0
,
heatPerFuel
:
0
,
sootYield
:
0
,
expansion
:
0
,
cooling
:
1.6
,
radiative
:
0
,
sootDecay
:
0.03
,
fuelDecay
:
2
,
buoyancy
:
0
,
sootWeight
:
6
,
vorticity
:
6
,
damping
:
0.04
,
forceCoupling
:
0.6
,
emission
:
0
,
temperature
:
2400
,
sootDensity
:
6
,
flameDensity
:
0
,
fuelDensity
:
0
,
g
:
0.3
,
sun
:
1.6
,
sky
:
1.0
,
fireLight
:
0
,
upres
:
2.8
,
upresScale
:
2.2
,
edgeFade
:
4
,
detailFreq
:
0.3
/
,
detailErode
:
0.12
,
detailHeat
:
0
,
nearFade
:
2.6
*
,
emptyBelow
:
0.05
,
stepScale
:
1.4
,
}
)
;
.
detailCenter
.
set
(
.
x
,
0
,
.
z
)
;
.
sootColor
.
set
(
.
cloudColor
)
;
.
sootColor
.
r
*=
0.72
;
.
sootColor
.
b
*=
1.25
;
.
sootColor
.
lerp
(
,
0.25
)
;
.
chroma
=
1.4
;
.
tint
.
copy
(
)
;
const
=
.
seed
%
97
;
gasSrc
(
,
.
x
,
0.9
*
,
.
z
,
1.2
*
,
1.9
,
0
,
true
,
1
,
1.8
,
,
0
,
-
2.6
,
0
,
2.8
,
6
)
;
for
(
let
=
0
;
<
5
;
++
)
{
const
=
+
*
1.2566
+
0.4
*
Math
.
sin
(
*
2.3
+
)
,
=
(
0.95
+
0.25
*
Math
.
sin
(
*
1.7
+
)
)
*
,
=
Math
.
cos
(
)
,
=
Math
.
sin
(
)
;
gasSrc
(
,
.
x
+
*
,
(
0.45
+
0.2
*
Math
.
sin
(
*
2.9
+
)
)
*
,
.
z
+
*
,
(
0.65
+
0.2
*
Math
.
cos
(
*
1.3
+
)
)
*
,
1.7
,
0
,
true
,
1
,
2.4
,
+
*
3.1
,
*
3.0
,
-
1.6
,
*
3.0
,
1.2
,
6
)
;
}
}
else
{
for
(
const
of
)
if
(
!
.
visible
)
{
.
cloud
=
;
break
;
}
if
(
.
cloud
)
{
.
cloud
.
visible
=
true
;
.
cloud
.
uniforms
.
uCloud
.
value
.
set
(
0
,
0
,
0
,
(
.
seed
%
97
)
*
0.173
)
;
.
cloud
.
uniforms
.
uCloudAlb
.
value
.
set
(
.
cloudColor
)
;
}
.
pos
.
set
(
.
x
,
1.6
*
,
.
z
)
;
.
radius
=
1.2
*
;
.
size
=
1.4
*
;
.
burst
(
120
*
.
fog
)
;
.
pos
.
copy
(
.
pos
)
;
.
radius
=
0.6
*
;
.
size
=
;
.
burst
(
90
*
.
fog
)
;
}
.
vortex
=
.
forces
.
acquire
(
)
;
if
(
.
vortex
)
{
const
=
.
vortex
;
.
type
=
1
;
.
p
[
0
]
=
0.6
*
;
.
p
[
1
]
=
2.6
*
;
.
p
[
2
]
=
-
0.1
;
.
p
[
3
]
=
0
;
.
w
=
4
*
;
.
pos
.
set
(
.
x
,
0
,
.
z
)
;
.
dir
.
set
(
0
,
1
,
0
)
;
}
.
pool
=
poolAcquire
(
.
x
,
.
z
,
3.6
*
,
.
seed
)
;
.
pos
.
copy
(
.
pos
)
;
.
radius
=
0.4
*
;
.
vel
.
set
(
0
,
0.5
,
0
)
;
.
burst
(
160
*
.
glow
)
;
if
(
.
light
)
{
.
light
.
intensity
=
3
*
.
glow
;
.
light
.
range
=
8
*
;
}
SPL
.
x
=
.
x
;
SPL
.
z
=
.
z
;
SPL
.
pattern
=
'noise'
;
SPL
.
radius
=
1.6
*
;
SPL
.
acid
=
0.3
*
.
corrosion
;
SPL
.
seed
=
.
seed
%
91
;
.
ground
.
splat
(
SPL
)
;
.
flash
(
0.05
*
.
glow
)
;
.
rig
.
shake
(
0.18
,
10
)
;
.
nextSplat
=
0.5
;
}
function
updateCloud
(
c, p, s, dt, flick
)
{
const
=
.
size
,
=
.
to
;
const
T
=
.
phase
===
'impact'
?
.
t
:
.
durations
.
impact
+
.
t
;
const
=
.
durations
.
impact
+
.
durations
.
linger
-
T
;
const
=
1
-
Math
.
exp
(
-
T
*
2.2
)
,
=
clamp01
(
/
2
)
;
const
=
sstep
(
0.3
,
0.85
*
(
.
durations
.
impact
+
.
durations
.
linger
)
,
T
)
;
const
=
.
gas
;
const
=
*
(
1.75
-
0.8
*
)
,
R
=
(
?
4.6
:
2.5
)
*
*
(
0.45
+
0.55
*
)
*
(
1
+
0.3
*
)
;
const
=
1.25
*
*
(
0.5
+
0.5
*
)
*
(
1
-
0.3
*
)
,
=
?
2.2
*
:
-
0.65
*
;
if
(
)
{
const
=
.
seed
%
97
,
=
Math
.
max
(
0
,
1
-
T
/
1.1
)
;
if
(
>
0
)
gasSrc
(
,
.
x
,
1.0
*
,
.
z
,
1.1
*
,
3.2
*
*
.
fog
,
0
,
false
,
1
,
2.2
,
+
T
*
0.5
,
0
,
-
2.0
,
0
,
2.4
,
1.5
)
;
const
=
sstep
(
0.3
,
0.8
,
T
)
*
clamp01
(
(
.
cloudTime
-
3.5
-
T
)
/
1.5
)
;
if
(
>
0
)
{
gasSrc
(
,
.
x
,
0.4
*
,
.
z
,
1.2
*
,
1.2
*
*
.
fog
,
0
,
false
,
1
,
1.4
,
+
11
+
T
*
0.3
,
0
,
-
0.1
,
0
,
2.2
,
1.5
)
;
const
=
(
1.2
+
2.6
*
(
1
-
Math
.
exp
(
-
T
/
2.2
)
)
)
*
;
for
(
let
=
0
;
<
5
;
++
)
{
const
=
*
1.2566
+
+
0.5
*
Math
.
sin
(
T
*
0.37
+
*
2.1
)
,
=
0.75
+
0.25
*
Math
.
sin
(
*
3.7
+
)
,
=
*
;
const
=
Math
.
cos
(
)
,
=
Math
.
sin
(
)
,
=
Math
.
sin
(
T
*
1.6
+
*
2.4
)
;
if
(
<=
0
)
continue
;
gasSrc
(
,
.
x
+
*
,
0.32
,
.
z
+
*
,
(
0.55
+
0.35
*
)
*
,
1.8
*
*
*
*
.
fog
,
0
,
false
,
1
,
2.6
,
+
*
3
+
T
*
0.6
,
*
1.5
,
-
0.05
,
*
1.5
,
0
,
1.8
)
;
}
}
.
sootDecay
=
0.2
+
0.3
*
sstep
(
2.5
,
5
,
T
)
+
1.5
*
(
1
-
)
*
(
1
-
)
;
.
sootWeight
=
4.2
-
2.4
*
sstep
(
1.2
,
3.5
,
T
)
;
}
else
{
if
(
.
cloud
)
{
.
cloud
.
position
.
set
(
.
x
,
,
.
z
)
;
.
cloud
.
scale
.
set
(
R
,
,
R
)
;
.
cloud
.
uniforms
.
uCloud
.
value
.
set
(
0.7
*
.
glow
,
T
,
*
,
.
cloud
.
uniforms
.
uCloud
.
value
.
w
)
;
.
cloud
.
uniforms
.
uCloudShape
.
value
.
x
=
;
.
cloud
.
uniforms
.
uCloudGlow
.
value
.
copy
(
)
.
lerp
(
,
0.3
)
;
}
.
pos
.
set
(
.
x
,
,
.
z
)
;
.
radius
=
0.75
*
R
;
.
size
=
1.3
*
;
.
rate
(
70
*
.
fog
*
,
)
;
.
pos
.
set
(
.
x
,
,
.
z
)
;
.
radius
=
0.5
*
R
;
.
size
=
;
.
rate
(
40
*
.
fog
*
,
)
;
.
pos
.
set
(
.
x
,
,
.
z
)
;
.
radius
=
0.55
*
R
;
.
vel
.
set
(
0
,
-
0.7
,
0
)
;
.
size
=
;
.
rate
(
70
*
.
fog
*
*
,
)
;
.
pos
.
set
(
.
x
,
0.2
,
.
z
)
;
.
radius
=
0.5
*
R
;
.
radial
=
1.3
*
;
.
size
=
0.9
*
;
.
rate
(
45
*
.
fog
*
*
,
)
;
}
if
(
.
pool
)
poolStyle
(
.
pool
,
,
0.42
*
,
0.2
*
)
;
if
(
T
>
0.4
)
{
.
pos
.
set
(
.
x
,
,
.
z
)
;
.
radius
=
0.7
*
R
;
.
vel
.
set
(
0
,
-
1.5
,
0
)
;
.
rate
(
170
*
.
drips
*
,
)
;
}
.
nextSplat
-=
;
if
(
.
nextSplat
<=
0
&&
>
0.2
)
{
.
nextSplat
=
0.45
;
SPL
.
x
=
.
x
;
SPL
.
z
=
.
z
;
SPL
.
pattern
=
'noise'
;
SPL
.
radius
=
0.85
*
R
;
SPL
.
acid
=
0.11
*
.
corrosion
;
SPL
.
seed
=
(
.
seed
+
T
*
13
)
%
97
;
.
ground
.
splat
(
SPL
)
;
}
.
froth
+=
14
*
*
*
.
bubbles
*
;
while
(
.
froth
>=
1
)
{
.
froth
-=
1
;
const
=
.
rand
(
)
*
6.2832
,
=
0.7
*
R
*
Math
.
sqrt
(
.
rand
(
)
)
;
froth
(
.
x
+
Math
.
cos
(
)
*
,
.
z
+
Math
.
sin
(
)
*
,
0.05
,
4
,
0.05
,
0.05
)
;
}
if
(
>
0.2
)
for
(
const
of
.
dummies
)
{
if
(
Math
.
hypot
(
.
pos
.
x
-
.
x
,
.
pos
.
z
-
.
z
)
>
R
*
0.85
)
continue
;
.
status
.
dissolve
=
Math
.
min
(
0.97
,
.
status
.
dissolve
+
(
0.1
+
0.11
*
.
corrosion
)
*
)
;
eatDummy
(
,
0.5
*
*
,
)
;
}
if
(
.
light
)
{
const
=
(
?
0.5
:
1
)
*
(
2.6
+
1.1
*
Math
.
sin
(
T
*
2.1
)
+
0.6
*
Math
.
sin
(
T
*
5.3
)
)
*
*
.
glow
*
*
;
.
light
.
intensity
=
Math
.
max
(
.
light
.
intensity
*
Math
.
exp
(
-
/
0.3
)
,
)
;
.
light
.
pos
.
set
(
.
x
,
?
0.5
:
*
0.8
,
.
z
)
;
}
}
}
,
}
;