Agent Harness · VibeGit
Agent Harness Публичная копия обвязки агентной разработки: гейты, journeys, скиллы и шаблоны. Без ключей и личных данных.
agent-harness / tools / spells-assets / ue / vfx / Spikes.js 659 строк · изменён 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
import * as THREE from 'three' ;
import { U , COMMON_GLSL , NOISE_GLSL , WORLD_GLSL , LIGHTS_GLSL , IMPACTS_GLSL , occluders } from './common.js' ;
import { instanced, put4 } from './Ribbons.js' ;
s seed
s s
rand seed
sides
layers
tipY
ang sides i sides
bulge sides
y
bounds
l l layers l bounds tipY l layers
bounds tipY
rings
l l layers l
ox oz k tw
lr
y0 bounds l l y1 bounds l
f jit
y y0 y1 y0 f
r y k
rings
lr f l
ang
rr r bulge i jit
a tw rr ox r y a tw rr oz r
top rings rings
apex top tipY top
cn
cut tipY
d p cn p cut cn p cn
d p cn d p cn d p cn d p
pos rock
pos a b c
i i i rock layer seam
r r rings r
rings r rings r
seam layer seam
i i sides i
j i sides
i j j layer seam
i i j layer seam
i i sides i top i apex top i sides top
pos rock
rand seed
crystals
tiltMain
crystals tiltMain
n
i i n i
az i n tilt
a az tilt tilt az tilt
r0
w
crystals az r0 az r0 a w w w
pos c0 c1 c2
s u v
c crystals
s c
u c s
c
t k
v c c h s t u t
lo hi c apex v c c c c
pos p q r
i i i
c0 c c c c c1 c c c c c2 s s s c
k k k
j k
lo k lo j hi j
lo k hi j hi k
hi k hi j apex
pos c0 c1 c2
g
pos variants v
variant variants v i
g pos
g variant
name size extra g name variants v name size
g
g
mat
mat
sh own
sh sh
sh sh
mat
mat
_m _q _qy _qt
_p _s _ax _v
c1 c3 c1 y x c3 y y y c1 y y
t x a b a t t t
max
rockGeo rockVariant
rockGeo rockGeo
rockGeo
iceGeo iceVariant
rockGeo iceGeo
name geo rockGeo iceGeo
attrs geo n max
geo
mat name
mesh geo mat
mesh
mesh
name mesh geo attrs attrs a
max
index
out
h
s s h s
h
h
h
h
k opts
v opts k
v v h k v h k v
h
h h h h
h h
h
h h
h
yaw h
_qy yaw
_q h
tilt
_ax h h
_q _qt _ax tilt
_q _qy
_p h h offset
_s h radial h axial h radial
h _p _q _s
c h
c h
c h
c h radial
dirty
h
h
h dt
t h h
t h
t h h h
ice h
offset radial axial tilt
t h
u t h
h u
h u
offset h h
radial h
h
h h occluders h h h
h h h
h
v t h h
offset v v h ice
radial ice v
axial ice v
tilt ice v v
h ice v
h offset radial axial tilt
h h h h h h h
fu ice t h
ice o e h
dirty o e e e e dirty
dirty o e e e e dirty
dirty o e e e e dirty
dirty o h h h h dirty
dirty o h h fu ice fu dirty
i i i
i
dirty a a a a
const
UP
=
new
THREE. Vector3
(
0
,
1
,
0
)
;
function
lcg
(
seed
)
{
let
=
(
>>>
0
)
||
1
;
return
(
)
=>
(
(
=
(
Math
.
imul
(
,
1664525
)
+
1013904223
)
>>>
0
)
/
4294967296
)
;
}
function
rockVariant
(
seed
)
{
const
=
lcg
(
*
7919
+
13
)
;
const
=
7
+
(
(
rand
(
)
*
3
)
|
0
)
;
const
=
7
+
(
(
rand
(
)
*
2
)
|
0
)
;
const
=
0.84
+
rand
(
)
*
0.08
;
const
=
Array
.
from
(
{
length
:
}
,
(
_, i
)
=>
(
(
+
(
rand
(
)
-
0.5
)
*
0.55
)
/
)
*
Math
.
PI
*
2
)
;
const
=
Array
.
from
(
{
length
:
}
,
(
)
=>
0.86
+
rand
(
)
*
0.26
)
;
const
prof
=
(
y
)
=>
0.1
+
0.9
*
Math
.
pow
(
Math
.
max
(
1
-
Math
.
max
(
,
0
)
/
1.02
,
0
)
,
0.9
)
;
const
=
[
-
0.25
]
;
for
(
let
=
1
;
<
;
++
)
.
push
(
*
Math
.
pow
(
/
,
0.85
)
+
(
rand
(
)
-
0.5
)
*
0.03
)
;
.
push
(
)
;
const
=
[
]
;
for
(
let
=
0
;
<
;
++
)
{
const
=
(
rand
(
)
-
0.5
)
*
0.12
,
=
(
rand
(
)
-
0.5
)
*
0.12
,
=
0.9
+
rand
(
)
*
0.2
,
=
(
rand
(
)
-
0.5
)
*
0.12
;
const
=
rand
(
)
;
const
=
[
]
+
(
?
0.006
:
0
)
,
=
[
+
1
]
;
for
(
const
[
,
]
of
[
[
0
,
0.04
]
,
[
0.5
,
0.1
]
,
[
1
,
0.04
]
]
)
{
const
=
+
(
-
)
*
;
const
=
prof
(
)
*
;
.
push
(
{
layer
:
,
seam
:
===
0
&&
>
0
,
pts
:
.
map
(
(
a, i
)
=>
{
const
=
*
[
]
*
(
1
+
(
rand
(
)
-
0.5
)
*
*
2
)
;
return
[
Math
.
cos
(
+
)
*
+
*
,
,
Math
.
sin
(
+
)
*
+
*
]
;
}
)
,
}
)
;
}
}
const
=
[
.
length
-
1
]
;
const
=
[
.
pts
[
0
]
[
0
]
*
0.2
+
(
rand
(
)
-
0.5
)
*
0.08
,
+
0.08
+
rand
(
)
*
0.1
,
.
pts
[
0
]
[
2
]
*
0.2
+
(
rand
(
)
-
0.5
)
*
0.08
]
;
const
=
new
THREE. Vector3
(
(
rand
(
)
-
0.5
)
*
1.2
,
1
,
(
rand
(
)
-
0.5
)
*
1.2
)
.
normalize
(
)
;
const
=
+
0.02
+
rand
(
)
*
0.04
;
const
flatten
=
(
p
)
=>
{
const
=
(
[
0
]
*
.
x
+
(
[
1
]
-
)
*
.
y
+
[
2
]
*
.
z
)
;
return
>
0
?
[
[
0
]
-
.
x
*
,
[
1
]
-
.
y
*
,
[
2
]
-
.
z
*
]
:
;
}
;
const
=
[
]
,
=
[
]
;
const
tri
=
(
a, b, c, layer, seam
)
=>
{
.
push
(
...
flatten
(
)
,
...
flatten
(
)
,
...
flatten
(
)
)
;
for
(
let
=
0
;
<
3
;
++
)
.
push
(
,
)
;
}
;
for
(
let
=
0
;
<
.
length
-
1
;
++
)
{
const
A
=
[
]
,
B
=
[
+
1
]
;
const
=
B
.
seam
?
1
:
0
,
=
?
A
.
layer
:
B
.
layer
;
for
(
let
=
0
;
<
;
++
)
{
const
=
(
+
1
)
%
;
tri
(
A
.
pts
[
]
,
B
.
pts
[
]
,
A
.
pts
[
]
,
,
)
;
tri
(
A
.
pts
[
]
,
B
.
pts
[
]
,
B
.
pts
[
]
,
,
)
;
}
}
for
(
let
=
0
;
<
;
++
)
tri
(
.
pts
[
]
,
,
.
pts
[
(
+
1
)
%
]
,
.
layer
,
0
)
;
return
{
,
}
;
}
function
iceVariant
(
seed
)
{
const
=
lcg
(
*
104729
+
7
)
;
const
=
[
]
;
const
=
new
THREE. Vector3
(
(
rand
(
)
-
0.5
)
*
0.18
,
1
,
(
rand
(
)
-
0.5
)
*
0.18
)
.
normalize
(
)
;
.
push
(
{
b
:
new
THREE. Vector3
(
0
,
-
0.25
,
0
)
,
a
:
,
w
:
0.3
+
rand
(
)
*
0.06
,
L
:
0.98
-
rand
(
)
*
0.06
,
T
:
0.24
+
rand
(
)
*
0.1
}
)
;
const
=
4
+
(
(
rand
(
)
*
3
)
|
0
)
;
for
(
let
=
0
;
<
;
++
)
{
const
=
(
(
+
rand
(
)
*
0.6
)
/
)
*
Math
.
PI
*
2
,
=
0.35
+
rand
(
)
*
0.45
;
const
=
new
THREE. Vector3
(
Math
.
cos
(
)
*
Math
.
sin
(
)
,
Math
.
cos
(
)
,
Math
.
sin
(
)
*
Math
.
sin
(
)
)
;
const
=
0.25
+
rand
(
)
*
0.25
;
const
=
0.1
+
rand
(
)
*
0.12
;
.
push
(
{
b
:
new
THREE. Vector3
(
Math
.
cos
(
)
*
,
-
0.25
,
Math
.
sin
(
)
*
)
,
,
,
L
:
0.25
+
rand
(
)
*
0.4
+
,
T
:
*
(
0.9
+
rand
(
)
*
0.9
)
}
)
;
}
const
=
[
]
,
=
[
]
,
=
[
]
,
=
[
]
;
const
=
new
THREE. Vector3
(
)
,
=
new
THREE. Vector3
(
)
,
=
new
THREE. Vector3
(
)
;
for
(
const
of
)
{
.
set
(
rand
(
)
-
0.5
,
rand
(
)
-
0.5
,
rand
(
)
-
0.5
)
.
cross
(
.
a
)
.
normalize
(
)
;
.
crossVectors
(
.
a
,
)
;
const
R
=
.
w
/
Math
.
cos
(
Math
.
PI
/
6
)
;
const
ring
=
(
h
)
=>
Array
.
from
(
{
length
:
6
}
,
(
_, k
)
=>
{
const
=
(
-
0.5
)
*
Math
.
PI
/
3
;
return
.
copy
(
.
b
)
.
addScaledVector
(
.
a
,
)
.
addScaledVector
(
,
Math
.
cos
(
)
*
R
)
.
addScaledVector
(
,
Math
.
sin
(
)
*
R
)
.
toArray
(
)
;
}
)
;
const
=
ring
(
0
)
,
=
ring
(
.
L
)
,
=
.
copy
(
.
b
)
.
addScaledVector
(
.
a
,
.
L
+
.
T
)
.
toArray
(
)
;
const
tri
=
(
p, q, r
)
=>
{
.
push
(
...
,
...
,
...
)
;
for
(
let
=
0
;
<
3
;
++
)
{
.
push
(
.
b
.
x
,
.
b
.
y
,
.
b
.
z
,
.
w
)
;
.
push
(
.
a
.
x
,
.
a
.
y
,
.
a
.
z
,
.
L
)
;
.
push
(
.
x
,
.
y
,
.
z
,
.
T
)
;
}
}
;
for
(
let
=
0
;
<
6
;
++
)
{
const
=
(
+
1
)
%
6
;
tri
(
[
]
,
[
]
,
[
]
)
;
tri
(
[
]
,
[
]
,
[
]
)
;
tri
(
[
]
,
[
]
,
)
;
}
}
return
{
,
,
,
}
;
}
function
merged
(
variants, extra
)
{
const
=
new
THREE. InstancedBufferGeometry
(
)
;
const
=
.
flatMap
(
(
v
)
=>
.
pos
)
;
const
=
.
flatMap
(
(
v, i
)
=>
new
Array
(
.
pos
.
length
/
3
)
.
fill
(
)
)
;
.
setAttribute
(
'position'
,
new
THREE. Float32BufferAttribute
(
,
3
)
)
;
.
setAttribute
(
'aVariant'
,
new
THREE. Float32BufferAttribute
(
,
1
)
)
;
for
(
const
[
,
]
of
)
.
setAttribute
(
,
new
THREE. Float32BufferAttribute
(
.
flatMap
(
(
v
)
=>
[
]
)
,
)
)
;
.
computeVertexNormals
(
)
;
return
;
}
const
INSTANCE_VERT
=
`
attribute float aVariant;
attribute vec4 aM0;
attribute vec4 aM1;
attribute vec4 aM2;
attribute vec4 aSpike;
attribute vec4 aSize;
mat4 spikeMatrix() { return transpose(mat4(aM0, aM1, aM2, vec4(0.0, 0.0, 0.0, 1.0))); }
// inverse-transpose for rotation x scale matrices (three's instancing trick)
vec3 spikeNormal(mat3 m, vec3 n) { return m * (n / vec3(dot(m[0], m[0]), dot(m[1], m[1]), dot(m[2], m[2]))); }
bool spikeOther() { return abs(aVariant - aSpike.x) > 0.5; }
`
;
const
ROCK_FRAG_PARS
=
COMMON_GLSL
+
NOISE_GLSL
+
WORLD_GLSL
+
LIGHTS_GLSL
+
IMPACTS_GLSL
+
`
varying vec3 vObj; // object space in metres, unrotated and unanimated (texture space)
varying vec2 vRock; // layer random, seam (ledge band)
varying vec4 vSpikeP; // variant, heat, fade, seed
varying vec4 vSizeP; // radius, height, -, -
varying vec3 vLean; // the spike's axis in world space (rims lean away from what threw them up)
uniform vec4 uRockLook; // strata contrast, vein width, heat glow scale, bump
uniform vec4 uSpikeOpts; // x rock receives capsule shadows, y ice does
float gBump; float gHeat; float gVein; float gStrata; float gHalo; float gDirt; float gFace; float gGlow;
uniform vec3 uRockDust; // dust settled on ledges and caked on the foot
// zero crossings of the fbm form a closed vein network; fwidth keeps them ~constant in pixels, and
// thin lines are scaled back so their coverage (and glow) is conserved instead of sparkling
float vein(float n, float w) { float fw = fwidth(n); return (1.0 - smoothstep(w, w + fw * 1.5, abs(n - 0.5))) * w / (w + 0.75 * fw); }
// one through-going fracture: a plane through the spike (mostly vertical, random strike), slightly
// jagged, limited to a patch of the plane and tapering to its tips. x: coverage, y: metres to it,
// z: taper (0 at the tips)
vec3 fracture(vec3 o, vec3 h, vec3 h2, float jag, float R, float H) {
float th = h2.x * 6.2831853;
vec3 n = normalize(vec3(cos(th), (h2.y - 0.5) * 0.7, sin(th)));
vec3 q = o - vec3((h.x - 0.5) * 0.9 * R, (0.2 + 0.55 * h.y) * H, (h.z - 0.5) * 0.9 * R);
float d = dot(q, n) + jag;
float L = (0.22 + 0.33 * h2.z) * H;
float taper = clamp(1.0 - dot(q - n * dot(q, n), q - n * dot(q, n)) / (L * L), 0.0, 1.0);
float w = 0.004 + 0.012 * taper * taper;
float fw = fwidth(d);
return vec3((1.0 - smoothstep(w * 0.3, w + fw, abs(d))) * w / (w + 0.75 * fw) * step(0.0, taper - 0.02), abs(d), taper);
}
`
;
const
ROCK_ALBEDO
=
`
{
vec3 o = vObj + vSpikeP.w * vec3(3.7, 1.3, 5.1);
vec4 nA = noise3v(o * 0.33);
vec4 nB = noise3v(o * 1.1 + 0.37);
vec4 nC = noise3v(o * 3.4 + 0.71); // grain: pits, crystals, fine roughness
// strata: horizontal bands warped by low noise, thinner bright laminae inside the bright bands
float b = vObj.y * 4.5 + (nA.r - 0.5) * 0.7 + vRock.x * 2.0;
float s = fract(b);
gStrata = smoothstep(0.62, 0.68, s) * (1.0 - smoothstep(0.84, 0.9, s)) * smoothstep(0.3, 0.55, nA.b);
float lam = smoothstep(0.8, 0.92, fract(vObj.y * 17.0 + nB.r * 0.8)) * 0.35;
vec3 basalt = vec3(0.04, 0.038, 0.036) * (0.7 + 0.6 * nB.r) * (0.85 + 0.3 * vRock.x) * (0.8 + 0.4 * nC.g);
vec3 strata = vec3(0.12, 0.1, 0.08) * (0.8 + 0.4 * nA.g) * (0.85 + 0.3 * nC.b);
vec3 albedo = mix(basalt, strata, clamp((gStrata + lam) * uRockLook.x, 0.0, 1.0));
// world-space decals: scorch darkens, frost whitens up-facing faces, magma heats the veins
vec3 wPos = cameraPosition + (vec4(-vViewPosition, 0.0) * viewMatrix).xyz;
vec4 wa, wb; vec3 gc;
impactWeights(wPos, wa, wb, gc);
albedo *= 1.0 - 0.7 * clamp(wa.x, 0.0, 1.0);
vec3 wN = normalize((vec4(vNormal, 0.0) * viewMatrix).xyz);
// it came up out of the ground: dust caked on the foot, settled on up-facing ledges (sunlit, pale),
// darker in the pits
float hu = vObj.y / max(vSizeP.y, 0.01);
float dirt = max(1.0 - smoothstep(0.02, 0.18 + 0.2 * nA.b, hu), smoothstep(0.45, 0.85, wN.y) * smoothstep(0.4, 0.62, nB.g + 0.1 * nC.r) * 0.75);
dirt *= 1.0 - 0.85 * smoothstep(0.05, 0.35, vSpikeP.y); // thrown up hot: soot, no settled dust
albedo *= 1.0 - 0.55 * smoothstep(0.1, 0.6, vSpikeP.y);
albedo = mix(albedo, uRockDust * (0.7 + 0.6 * nC.r), dirt);
albedo *= 0.75 + 0.25 * smoothstep(0.25, 0.6, nC.a);
albedo = mix(albedo, vec3(0.7, 0.8, 0.9), clamp(wa.y, 0.0, 1.0) * smoothstep(-0.2, 0.6, wN.y) * smoothstep(0.35, 0.6, nB.g));
gHeat = clamp(vSpikeP.y + wa.w, 0.0, 1.0);
// three straight-ish fractures through the spike (glowing deep inside when hot, a dull-red rim that
// cools to dark within a few centimetres), fine dark cracks (albedo only), broken ledge seams
// (dark; hot only on the face towards the source)
float crack = vein(nB.r, uRockLook.y * 0.35);
float sd = mod(vSpikeP.w, 4093.0), jag = (nB.r - 0.5) * 0.016 + (nC.g - 0.5) * 0.006;
// (hottest where the fracture is widest and low down, nearer the heat; cooler towards its tips)
float warm = 1.0 - 0.65 * smoothstep(0.1, 0.9, hu);
gVein = 0.0; gHalo = 0.0; gGlow = 0.0;
for (int k = 0; k < 3; k++) {
vec3 hk = hash33(vec3(sd, float(k), 3.1));
vec3 f = fracture(vObj, hk, hash33(vec3(sd, float(k), 8.7)), jag, vSizeP.x, vSizeP.y) * (k < 2 || hk.y > 0.5 ? 1.0 : 0.0);
gVein = max(gVein, f.x);
gGlow = max(gGlow, f.x * f.z * warm);
gHalo = max(gHalo, exp(-f.y / 0.02) * f.z * warm);
}
// the broken face towards the source (the side the spike leans away from), lower part: hot rock
// under a crust that has started to skin over in patches
vec2 lean = vLean.xz / max(length(vLean), 1e-4);
float face = smoothstep(0.2, 0.75, dot(normalize(wN.xz + 1e-5), -lean / max(length(lean), 1e-4))) * smoothstep(0.1, 0.35, length(lean)) * smoothstep(0.15, 0.5, length(wN.xz));
gFace = face * (1.0 - smoothstep(0.0, 0.22, hu + (nB.g - 0.5) * 0.15)) * smoothstep(0.45, 0.75, nB.r + (nC.r - 0.5) * 0.3);
albedo *= 1.0 - 0.6 * face * smoothstep(0.1, 0.5, vSpikeP.y); // the fresh hot face: dark, unweathered basalt
float seam = vRock.y * smoothstep(0.45, 0.7, nA.g);
gVein = max(gVein, seam * face);
gGlow = max(gGlow, seam * face * warm * 0.6);
gBump = (nB.r * 0.45 + nA.r * 0.3 + nC.r * 0.25) - gVein * 0.6 - crack * 0.2 + gStrata * 0.15;
gDirt = dirt;
diffuseColor.rgb = albedo * (1.0 - max(max(gVein, seam) * 0.75, max(crack * 0.3, gHalo * 0.25)));
// crumble: alpha-to-coverage, dithered so 4 samples give a smooth fade
float fade = vSpikeP.z;
diffuseColor.a = fade >= 1.0 ? 1.0 : clamp(fade + (ign(gl_FragCoord.xy) - 0.5) * 0.25, 0.0, 1.0);
if (diffuseColor.a < 0.01) discard;
}
`
;
const
ROCK_BUMP
=
`
{
vec3 dpdx = dFdx(-vViewPosition), dpdy = dFdy(-vViewPosition);
float dhx = dFdx(gBump), dhy = dFdy(gBump);
vec3 r1 = cross(dpdy, normal), r2 = cross(normal, dpdx);
float det = dot(dpdx, r1);
vec3 grad = sign(det) * (dhx * r1 + dhy * r2) * uRockLook.w * 0.02;
normal = normalize(abs(det) * normal - grad);
}
`
;
const
ROCK_EMIT
=
`
{
// heat: deep in the fractures at the blackbody colour of ~800..1500 K, a dull-red rim beside them,
// the broken face below them; the crust itself only near full heat
float T = mix(800.0, 1500.0, gHeat);
float h2 = gHeat * gHeat;
totalEmissiveRadiance += (blackbody(T) * gGlow * h2 * 10.0
+ blackbody(T * 0.7) * (gHalo * h2 * 0.9 + gFace * h2 * 0.35 + smoothstep(0.85, 1.0, gHeat) * 0.05)) * uRockLook.z;
}
`
;
const
SPELL_LIGHTS
=
`
{
gLightNoShadow = uSpikeOpts.x < 0.5;
vec3 wN = normalize((vec4(normal, 0.0) * viewMatrix).xyz);
vec3 wP = cameraPosition + (vec4(-vViewPosition, 0.0) * viewMatrix).xyz;
vec3 sd, ss;
spellLightPBR(wP, wN, normalize(cameraPosition - wP), material.roughness, material.specularColor, material.diffuseColor, sd, ss);
reflectedLight.directDiffuse += sd;
reflectedLight.directSpecular += ss;
}
`
;
function
rockMaterial
(
own
)
{
const
=
new
THREE. MeshStandardMaterial
(
{
color
:
0xffffff
,
roughness
:
0.85
,
metalness
:
0
,
alphaToCoverage
:
true
}
)
;
.
onBeforeCompile
=
(
sh
)
=>
{
Object
.
assign
(
.
uniforms
,
U
,
)
;
.
vertexShader
=
.
vertexShader
.
replace
(
'#include <common>'
,
` #include <common>
${ INSTANCE_VERT }
attribute vec2 aRock;
varying vec3 vObj;
varying vec2 vRock;
varying vec4 vSpikeP;
varying vec4 vSizeP;
varying vec3 vLean;
mat4 gM; `
)
.
replace
(
'#include <beginnormal_vertex>'
,
` gM = spikeMatrix();
vec3 objectNormal = spikeNormal(mat3(gM), normal); `
)
.
replace
(
'#include <begin_vertex>'
,
` vec3 transformed = spikeOther() ? vec3(0.0) : (gM * vec4(position, 1.0)).xyz;
vObj = position * vec3(aSize.x, aSize.y, aSize.x);
vRock = aRock; vSpikeP = aSpike; vSizeP = aSize; vLean = mat3(gM) * vec3(0.0, 1.0, 0.0); `
)
;
.
fragmentShader
=
.
fragmentShader
.
replace
(
'#include <common>'
,
'#include <common>\n'
+
ROCK_FRAG_PARS
)
.
replace
(
'#include <color_fragment>'
,
'#include <color_fragment>\n'
+
ROCK_ALBEDO
)
.
replace
(
'#include <roughnessmap_fragment>'
,
'float roughnessFactor = mix(mix(0.88, 0.62, gStrata) - gVein * 0.25, 0.97, gDirt);'
)
.
replace
(
'#include <normal_fragment_maps>'
,
'#include <normal_fragment_maps>\n'
+
ROCK_BUMP
)
.
replace
(
'#include <emissivemap_fragment>'
,
'#include <emissivemap_fragment>\n'
+
ROCK_EMIT
)
.
replace
(
'#include <lights_fragment_end>'
,
'#include <lights_fragment_end>\n'
+
SPELL_LIGHTS
)
;
}
;
.
customProgramCacheKey
=
(
)
=>
'ue-spike-rock'
;
return
;
}
const
ICE_VERT
=
INSTANCE_VERT
+
`
attribute vec4 c0;
attribute vec4 c1;
attribute vec4 c2;
out vec3 vWorld;
out vec3 vN;
out vec3 vLocal;
flat out vec4 vC0;
flat out vec4 vC1;
flat out vec4 vC2;
flat out vec3 vInv0;
flat out vec3 vInv1;
flat out vec3 vInv2;
flat out vec4 vSpikeP;
flat out vec4 vSizeP;
void main() {
mat4 M = modelMatrix * spikeMatrix();
mat3 L = mat3(M);
vec4 wp = M * vec4(position, 1.0);
vWorld = wp.xyz;
vN = normalize(spikeNormal(L, normal));
vLocal = position;
mat3 inv = inverse(L);
vInv0 = inv[0]; vInv1 = inv[1]; vInv2 = inv[2];
vC0 = c0; vC1 = c1; vC2 = c2;
vSpikeP = aSpike; vSizeP = aSize;
gl_Position = spikeOther() ? vec4(2.0, 2.0, 2.0, 1.0) : projectionMatrix * viewMatrix * wp;
} `
;
const
ICE_FRAG
=
COMMON_GLSL
+
NOISE_GLSL
+
WORLD_GLSL
+
LIGHTS_GLSL
+
`
uniform mat4 projectionMatrix; // three only declares it in the vertex stage
uniform highp sampler2D uSceneColor;
uniform highp sampler2D uSceneDepth;
uniform samplerCube uSkyCube;
uniform vec3 uSunDir;
uniform vec3 uSunColor;
uniform vec3 uAmbient;
uniform vec3 uIceAbsorb; // Beer-Lambert sigma per metre (red highest -> cyan)
uniform vec4 uIceLook; // ior, frost, interior, glints
uniform vec3 uIceGlow; // growth-front emission (linear HDR)
uniform vec4 uSpikeOpts; // x rock receives capsule shadows, y ice does
in vec3 vWorld;
in vec3 vN;
in vec3 vLocal;
flat in vec4 vC0;
flat in vec4 vC1;
flat in vec4 vC2;
flat in vec3 vInv0;
flat in vec3 vInv1;
flat in vec3 vInv2;
flat in vec4 vSpikeP;
flat in vec4 vSizeP;
out vec4 fragColor;
// half-space dot(p, N) <= off: nearest exit along d, and the two largest signed distances (the
// fragment's own face ~0 and the nearest other face = distance to the nearest edge)
void icePlane(vec3 N, float off, vec3 o, vec3 d, inout float tMin, inout vec3 nExit, inout float s1, inout float s2) {
float dn = dot(d, N), sd = dot(o, N) - off;
if (dn > 1e-5) { float t = -sd / dn; if (t < tMin) { tMin = t; nExit = N; } }
if (sd > s1) { s2 = s1; s1 = sd; } else if (sd > s2) s2 = sd;
}
float crystalExit(vec3 o, vec3 d, out vec3 nExit, out float edge) {
vec3 b = vC0.xyz, a = vC1.xyz, s = vC2.xyz, u = cross(a, s);
float w = vC0.w, L = vC1.w, T = vC2.w;
vec3 apex = b + a * (L + T);
float tMin = 1e3, s1 = -1e3, s2 = -1e3, il = inversesqrt(T * T + w * w);
nExit = a;
vec2 cs = vec2(1.0, 0.0); // side k at k x 60 degrees, rotated by recurrence (no trig)
for (int k = 0; k < 6; k++) {
vec3 n = cs.x * s + cs.y * u;
icePlane(n, dot(b, n) + w, o, d, tMin, nExit, s1, s2);
vec3 m = (n * T + a * w) * il;
icePlane(m, dot(apex, m), o, d, tMin, nExit, s1, s2);
cs = vec2(cs.x * 0.5 - cs.y * 0.8660254, cs.y * 0.5 + cs.x * 0.8660254);
}
icePlane(-a, -dot(b, a), o, d, tMin, nExit, s1, s2);
edge = -s2;
return clamp(tMin, 0.0, 4.0);
}
vec2 toUV(vec3 p) { vec4 c = projectionMatrix * viewMatrix * vec4(p, 1.0); return c.xy / c.w * 0.5 + 0.5; }
void main() {
vec3 N = normalize(vN);
vec3 V = normalize(cameraPosition - vWorld);
float NoV = max(dot(N, V), 1e-3);
float ior = uIceLook.x;
mat3 inv = mat3(vInv0, vInv1, vInv2);
vec3 size = vec3(vSizeP.x, vSizeP.y, vSizeP.x);
float hf = vLocal.y; // 0 at the ground, ~1 at the main tip
// --- through the crystal: enter, exact convex exit, refract out (or TIR) -----------------
vec3 R = refract(-V, N, 1.0 / ior);
vec3 nL, ld = inv * R;
float edge;
float thick = crystalExit(vLocal, ld, nL, edge);
vec3 nX = normalize(nL * inv); // exit face normal in world space (inverse transpose)
vec3 R2 = refract(R, -nX, ior);
float tir = dot(R2, R2) < 1e-4 ? 1.0 : 0.0;
if (tir > 0.5) R2 = reflect(R, nX);
vec3 pExit = vWorld + R * thick;
vec2 uv = gl_FragCoord.xy / uResolution;
float iceZ = linearDepth(gl_FragCoord.z);
float sceneZ = linearDepth(texture(uSceneDepth, uv).r);
float behind = clamp(sceneZ - iceZ, 0.2, 3.0);
vec2 ruv = clamp(toUV(pExit + R2 * behind * 0.5), 0.002, 0.998);
// the bent ray landed on something in front of the ice: fall back to the straight view (UW)
float rZ = linearDepth(texture(uSceneDepth, ruv).r);
ruv = mix(uv, ruv, smoothstep(iceZ - 0.05, iceZ + 0.25, rZ));
vec3 bg = textureLod(uSceneColor, ruv, 0.0).rgb;
float path = thick + tir * vSizeP.x * 0.6; // TIR: one more trip through the body
vec3 Tr = exp(-uIceAbsorb * path);
// --- light: spell lights (GGX on the flat facet), sun, sky -------------------------------
vec3 sd, ss;
gLightNoShadow = uSpikeOpts.y < 0.5; // capsule shadows per ice pixel cost more than they show
spellLightPBR(vWorld, N, V, 0.04, vec3(0.018), vec3(1.0), sd, ss);
float NoL = max(dot(N, uSunDir), 0.0);
vec3 H = normalize(uSunDir + V);
float a = 0.0016; // GGX alpha for roughness 0.04
float sunSpec = spellD_GGX(max(dot(N, H), 0.0), a) * spellV_Smith(NoV, NoL, a) * NoL * PI;
vec3 irr = uAmbient + uSunColor * NoL + sd; // diffuse radiance factor for white, this facet
vec3 irrOmni = uAmbient + uSunColor * 0.5 + sd; // light scattered inside (one light loop only)
// --- fake interior: 3 taps along the refracted ray read as bubbles, veils and cracks -----
float seedOff = vSpikeP.w * 0.13;
float scat = 0.0;
vec3 ldS = ld * size; // object-space metres per metre of path
for (int i = 1; i <= 3; i++) {
float f = float(i) * 0.25;
vec3 q = vLocal * size + ldS * thick * f;
vec4 n = noise3v(q * 0.42 + seedOff);
float veil = smoothstep(0.6, 0.95, n.r) * 0.35;
float bubble = smoothstep(0.84, 0.95, n.a) * 1.6;
float crack = smoothstep(0.03, 0.0, abs(n.g - 0.55)) * smoothstep(0.3, 0.6, n.r) * 1.4;
scat += (veil + bubble + crack) * exp(-uIceAbsorb.r * thick * f);
}
scat *= uIceLook.z / 3.0;
// --- frost: rough white on edges, at the base and in noisy patches ------------------------
// (edge band scales with the crystal: thin crystals keep clear faces)
vec4 fn = noise3v(vLocal * size * 1.7 + seedOff);
float ew = vC0.w * 0.07; // edge distance spans 0 .. 0.5 apothem across a face
vec4 fe = noise3v(vLocal * size * 5.0 + seedOff); // rime grows unevenly along the edges
float ewl = ew * (0.2 + 1.8 * fe.r * fe.r);
float frost = smoothstep(ewl, ewl * 0.15, edge - (fe.g - 0.5) * ew * 0.8);
frost = max(frost, smoothstep(0.12, 0.0, hf + (fn.g - 0.5) * 0.12));
frost = max(frost, smoothstep(0.84, 0.97, fn.b) * 0.3);
// growth front: everything above it is still forming (milky, glowing), a bright band on it
float front = vSizeP.z, glow = vSizeP.w;
float above = smoothstep(front - 0.02, front + 0.02, hf) * glow;
frost = clamp(max(frost, above) * uIceLook.y, 0.0, 1.0);
// --- compose ------------------------------------------------------------------------------
float F = 0.018 + 0.982 * pow(1.0 - NoV, 5.0);
vec3 refl = textureLod(uSkyCube, reflect(-V, N), 0.0).rgb;
// transmitted background + cyan in-scatter of the column (UW's water body) + interior features
vec3 inscat = vec3(0.04, 0.34, 0.62) * irrOmni * 0.5;
vec3 body = bg * Tr + inscat * (1.0 - Tr) + vec3(0.8, 0.92, 1.0) * irrOmni * scat * 0.2;
body += tir * inscat * 0.4;
vec3 col = body * (1.0 - F) + (refl * F + ss + uSunColor * F * sunSpec) * (1.0 - frost * 0.8);
vec3 frostCol = vec3(0.82, 0.9, 1.0) * irr;
col = mix(col, frostCol, frost * 0.85);
// glints: tiny random facets whose hash changes with the view direction and time (they flick
// on and off as you orbit, like real ice), lit by whatever reaches this face; faded when sub-pixel
vec3 gq = vLocal * size * 26.0;
vec3 cell = floor(gq);
vec3 gh = hash33(cell + floor(V * 5.0) * 17.0);
float tw = pow(0.5 + 0.5 * sin(uTime * 7.0 + gh.y * 60.0), 6.0);
float spot = smoothstep(0.35, 0.0, length(fract(gq) - 0.5 - (gh - 0.5) * 0.4));
float px = length(fwidth(gq));
float glint = step(0.93, gh.x) * spot * tw * smoothstep(1.2, 0.4, px) * (0.4 + frost);
col += glint * (irr * 6.0 + ss * 0.5) * uIceLook.w;
float band = exp(-abs(hf - front) * 26.0) * glow;
col += uIceGlow * (band * 3.0 + above * 0.35);
float fade = vSpikeP.z;
float alpha = fade >= 1.0 ? 1.0 : clamp(fade + (ign(gl_FragCoord.xy) - 0.5) * 0.25, 0.0, 1.0);
if (alpha < 0.01) discard;
fragColor = vec4(col, alpha);
} `
;
const
DEFAULTS
=
{
height
:
2
,
radius
:
0.4
,
material
:
'rock'
,
delay
:
0
,
rise
:
0.15
,
life
:
4
,
crumble
:
0.6
,
heat
:
0
,
seed
:
0
}
;
const
=
new
THREE. Matrix4
(
)
,
=
new
THREE. Quaternion
(
)
,
=
new
THREE. Quaternion
(
)
,
=
new
THREE. Quaternion
(
)
;
const
=
new
THREE. Vector3
(
)
,
=
new
THREE. Vector3
(
)
,
=
new
THREE. Vector3
(
)
,
=
new
THREE. Vector3
(
)
;
const
easeOutBack
=
(
x
)
=>
{
const
=
1.70158
,
=
+
1
,
=
-
1
;
return
1
+
*
*
*
+
*
*
;
}
;
const
smooth
=
(
a, b, x
)
=>
{
const
=
Math
.
min
(
1
,
Math
.
max
(
0
,
(
-
)
/
(
-
)
)
)
;
return
*
*
(
3
-
2
*
)
;
}
;
export
class
Spikes
{
constructor
(
{ max = 48 } = { }
)
{
this
.
max
=
;
this
.
uniforms
=
{
...
U
,
uRockLook
:
{
value
:
new
THREE. Vector4
(
1
,
0.022
,
1
,
1
)
}
,
uRockDust
:
{
value
:
new
THREE. Color
(
0.15
,
0.13
,
0.11
)
}
,
uIceAbsorb
:
{
value
:
new
THREE. Vector3
(
2.6
,
0.75
,
0.3
)
}
,
uIceLook
:
{
value
:
new
THREE. Vector4
(
1.31
,
1
,
1
,
1
)
}
,
uIceGlow
:
{
value
:
new
THREE. Vector3
(
0.6
,
1.6
,
2.6
)
}
,
uSpikeOpts
:
{
value
:
new
THREE. Vector4
(
0
,
0
,
0
,
0
)
}
,
}
;
const
=
merged
(
[
0
,
1
,
2
,
3
]
.
map
(
)
,
[
[
'rock'
,
2
]
]
)
;
.
setAttribute
(
'aRock'
,
.
attributes
.
rock
)
;
.
deleteAttribute
(
'rock'
)
;
const
=
merged
(
[
0
,
1
,
2
,
3
]
.
map
(
)
,
[
[
'c0'
,
4
]
,
[
'c1'
,
4
]
,
[
'c2'
,
4
]
]
)
;
this
.
triangles
=
{
rock
:
.
attributes
.
position
.
count
/
12
,
ice
:
.
attributes
.
position
.
count
/
12
}
;
this
.
kinds
=
{
}
;
for
(
const
[
,
]
of
[
[
'rock'
,
]
,
[
'ice'
,
]
]
)
{
const
=
[
'aM0'
,
'aM1'
,
'aM2'
,
'aSpike'
,
'aSize'
]
.
map
(
(
n
)
=>
instanced
(
,
,
)
)
;
.
instanceCount
=
0
;
const
=
===
'rock'
?
rockMaterial
(
this
.
uniforms
)
:
new
THREE. ShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
uniforms
:
this
.
uniforms
,
vertexShader
:
ICE_VERT
,
fragmentShader
:
ICE_FRAG
,
alphaToCoverage
:
true
,
}
)
;
const
=
new
THREE. Mesh
(
,
)
;
.
frustumCulled
=
false
;
.
visible
=
false
;
this
.
kinds
[
]
=
{
,
,
,
arrays
:
.
map
(
(
a
)
=>
.
array
)
,
count
:
0
}
;
}
this
.
kinds
.
rock
.
mesh
.
renderOrder
=
-
1
;
this
.
opaque
=
new
THREE. Group
(
)
;
this
.
opaque
.
add
(
this
.
kinds
.
rock
.
mesh
)
;
this
.
refract
=
new
THREE. Group
(
)
;
this
.
refract
.
add
(
this
.
kinds
.
ice
.
mesh
)
;
this
.
spikes
=
Array
.
from
(
{
length
:
}
,
(
_, index
)
=>
(
{
,
active
:
false
,
...
DEFAULTS
,
pos
:
new
THREE. Vector3
(
)
,
dir
:
new
THREE. Vector3
(
0
,
1
,
0
)
,
age
:
0
,
state
:
'waiting'
,
emerge
:
0
,
fade
:
1
,
matrix
:
new
THREE. Matrix4
(
)
,
capsule
:
{
a
:
new
THREE. Vector3
(
)
,
b
:
new
THREE. Vector3
(
)
,
radius
:
0
}
,
occluder
:
null
,
top
(
out
)
{
return
.
set
(
0
,
1.02
,
0
)
.
applyMatrix4
(
this
.
matrix
)
;
}
,
release
(
)
{
this
.
active
=
false
;
this
.
occluder
?.
release
(
)
;
this
.
occluder
=
null
;
}
,
}
)
)
;
}
spawn
(
opts = { }
)
{
let
=
null
;
for
(
const
of
this
.
spikes
)
if
(
!
.
active
)
{
=
;
break
;
}
if
(
!
)
return
null
;
Object
.
assign
(
,
DEFAULTS
)
;
.
dir
.
set
(
0
,
1
,
0
)
;
.
seed
=
(
Math
.
random
(
)
*
16777216
)
|
0
;
for
(
const
in
)
{
const
=
[
]
;
if
(
&&
.
isVector3
)
[
]
.
copy
(
)
;
else
[
]
=
;
}
.
dir
.
normalize
(
)
;
.
age
=
0
;
.
state
=
'waiting'
;
.
emerge
=
0
;
.
fade
=
1
;
.
occluder
?.
release
(
)
;
.
occluder
=
null
;
.
active
=
true
;
this
.
_pose
(
,
-
.
height
,
0.75
,
1
,
0
)
;
return
;
}
_pose
(
h, offset, radial, axial, tilt
)
{
const
=
(
(
.
seed
*
0.6180339887
)
%
1
)
*
Math
.
PI
*
2
;
.
setFromAxisAngle
(
UP
,
)
;
.
setFromUnitVectors
(
UP
,
.
dir
)
;
if
(
)
{
.
set
(
Math
.
cos
(
.
seed
)
,
0
,
Math
.
sin
(
.
seed
)
)
;
.
multiply
(
.
setFromAxisAngle
(
,
)
)
;
}
.
multiply
(
)
;
.
copy
(
.
pos
)
.
addScaledVector
(
.
dir
,
)
;
.
set
(
.
radius
*
,
.
height
*
,
.
radius
*
)
;
.
matrix
.
compose
(
,
,
)
;
const
=
.
capsule
;
.
a
.
set
(
0
,
0.1
,
0
)
.
applyMatrix4
(
.
matrix
)
;
.
b
.
set
(
0
,
0.78
,
0
)
.
applyMatrix4
(
.
matrix
)
;
.
radius
=
.
radius
*
*
0.5
;
}
update
(
dt
)
{
let
=
false
;
this
.
kinds
.
rock
.
count
=
this
.
kinds
.
ice
.
count
=
0
;
for
(
const
of
this
.
spikes
)
{
if
(
!
.
active
)
continue
;
.
age
+=
;
const
=
.
age
-
.
delay
;
if
(
<
0
)
{
.
state
=
'waiting'
;
continue
;
}
if
(
>=
.
life
+
.
crumble
)
{
.
release
(
)
;
continue
;
}
const
=
.
material
===
'ice'
;
let
,
=
1
,
=
1
,
=
0
;
if
(
<
.
life
)
{
const
=
Math
.
min
(
1
,
/
Math
.
max
(
.
rise
,
1e-3
)
)
;
.
state
=
<
1
?
'rising'
:
'standing'
;
.
emerge
=
easeOutBack
(
)
;
=
(
.
emerge
-
1
)
*
.
height
;
=
0.75
+
0.25
*
Math
.
min
(
.
emerge
,
1
)
;
.
fade
=
1
;
if
(
!
.
occluder
)
.
occluder
=
.
add
(
.
capsule
.
a
,
.
capsule
.
b
,
.
capsule
.
radius
,
2
)
;
}
else
{
if
(
.
state
!==
'crumbling'
)
{
.
occluder
?.
release
(
)
;
.
occluder
=
null
;
}
.
state
=
'crumbling'
;
const
=
(
-
.
life
)
/
Math
.
max
(
.
crumble
,
1e-3
)
;
=
-
*
*
.
height
*
(
?
0.25
:
0.55
)
;
=
1
-
(
?
0.45
:
0.3
)
*
;
=
1
-
(
?
0.35
:
0.2
)
*
;
=
(
?
0.05
:
0.22
)
*
*
;
.
fade
=
1
-
smooth
(
?
0.1
:
0.25
,
1
,
)
;
}
this
.
_pose
(
,
,
,
,
)
;
if
(
.
occluder
)
{
.
occluder
.
a
.
copy
(
.
capsule
.
a
)
;
.
occluder
.
b
.
copy
(
.
capsule
.
b
)
;
.
occluder
.
radius
=
.
capsule
.
radius
;
}
const
=
?
Math
.
min
(
1
,
/
Math
.
max
(
.
rise
*
4
,
0.3
)
)
:
1
;
const
K
=
this
.
kinds
[
?
'ice'
:
'rock'
]
,
X
=
K
.
arrays
,
=
K
.
count
*
4
,
=
.
matrix
.
elements
;
=
put4
(
X
[
0
]
,
,
[
0
]
,
[
4
]
,
[
8
]
,
[
12
]
)
||
;
=
put4
(
X
[
1
]
,
,
[
1
]
,
[
5
]
,
[
9
]
,
[
13
]
)
||
;
=
put4
(
X
[
2
]
,
,
[
2
]
,
[
6
]
,
[
10
]
,
[
14
]
)
||
;
=
put4
(
X
[
3
]
,
,
.
seed
&
3
,
.
heat
,
.
fade
,
(
.
seed
%
997
)
/
997
)
||
;
=
put4
(
X
[
4
]
,
,
.
radius
,
.
height
,
*
1.3
-
0.05
,
?
1
-
smooth
(
0.75
,
1
,
)
:
0
)
||
;
K
.
count
++
;
}
for
(
let
=
0
;
<
2
;
++
)
{
const
K
=
?
this
.
kinds
.
ice
:
this
.
kinds
.
rock
;
K
.
geo
.
instanceCount
=
K
.
count
;
K
.
mesh
.
visible
=
K
.
count
>
0
;
if
(
K
.
count
&&
)
for
(
const
of
K
.
attrs
)
{
.
clearUpdateRanges
(
)
;
.
addUpdateRange
(
0
,
K
.
count
*
4
)
;
.
needsUpdate
=
true
;
}
}
}
get
live
(
)
{
return
this
.
kinds
.
rock
.
count
+
this
.
kinds
.
ice
.
count
;
}
}