import*asTHREEfrom'three';import{U,COMMON_GLSL,LINES_BLENDING,FX_VERT_HEAD,FX_FRAG_HEAD,FX_OUT_GLSL,FX_BLENDING,ARENA, arenaSDF }from'../../vfx/common.js';import{ instanced }from'../../vfx/Ribbons.js';// Starfall (Arcane hero). A pocket of night opens over the target: a raymarched lens of dark// nebula (absorbing, albedo 0 so it skips lighting) whose log-spiral arms unfurl from the centre// and turn with differential rotation, sprinkled with twinkling stars. An arcane circle draws// itself on the floor and motes rise from its rim. Then stars ignite inside the canopy and streak// down in parallel (one radiant per cast, like a meteor shower): each a 4-point diffraction-spike// head sprite, a full-res white-hot train with glitter cells and a half-res soft glow train,// shedding sparkles, carrying a shadowed light. Each lands in a starburst flare with sparks,// stardust that settles and paints glow, a ground shock ring and a glow + corruption ring (violet
_a _b _c
sstep
x z
fx
spark
glitter
gather
rise
dust
wisp
smoke
ejecta
puff
col core glow lightCol skyLightCol
vCore vCol vGlow
cC cK cG
p
p cC p cK p cG
cC p cK p cG p
colcC corecK glowcG
vCorecore core core vColcol col col vGlowglow glow glow
lightColcolcore
skyLightColglowcol
cK cC
cK cG
col
canopies
i i i
v fx
vCore vCol vGlow
v
canopiesv
trainU vCore vCol vGlow
cores trainU
glows trainU
fxcores
fxglows
sgeo
sgeo
sgeo
aA sgeo aB sgeo
sgeo
sprites sgeo
sprites
sprites
fxsprites
kgeo
kgeo sgeo
kgeosgeo
kA kgeo kB kgeo
kgeo
skyStars kgeo
skyStars
skyStars
fxskyStars
pops
popHead
q popspopHead popHead popHead
qpos q size q life q
q c k q c k q c k
st st st st st
n p p
d n d d d
i i n i di i
i n i i j fx i t di di dj dj t
a0 fx
k k n k
st dk fin k n
st fin st st st st st st fx
fin
c stfxc std
st p
i dk
r d i n fx a a0 i fx
std a r d a r
st p fx
st st st
std
_add d
st _bst _ad std
ststst st
st p fin fx
st fin k fx n
st stst
st st st stst
st cores st glows
st st
st st
st st core p
best bi
sl d
sl
k sl sl
k bi bi k best sl
best best st best best st
d
st st
st st p st
d
d d st
g st fin st z st
sl d sl st
sl sl
sl fin z p
sl fin z
slg
g fin z col p fin
_ag z core fin p fin
sparkg spark fin st
sparkfin p z
dustspark dust fin dust fin
dustfin p
glitterspark glitter glitter fin
glitterfin p
glitter
spark glitter
onFloor g
g g g g fin z
fin fin fin
fin p onFloor
fx
onFloor
g g c d
fin z fin fin fin
fin fin fin z
fx
fin d fx
g g
ejectag ejecta fin st
ejectafin z
puffg puff fin
pufffin z
g g fxg g fin fin
fxinsthitg fin
reach fin z
dm fx
dist dm g dm g
dist reach
_bdm g dm g
dist _bst
dm_b fin dist reach
fin
d
fx _agg z col
fx p
fx
fx fx fx
d fx
d d dgg d d d d d
fx z
st d st st st st st
sl d sl sl sl sl sl
d d d
d d d
d d d d
d
len st st st st
_cstst len
h st g st
h
hst st st st
h_c _c _c
hst len
h
g
gst st st st
g_c _c _c
g len
g
k k k
p d c
name
d d d d c d d d
c c p c
d p d p d p
c dfxc dc c
side c tanA p
_ac side c side_bc c
_a _a
_a
d_atanA
p d
ddd d
dc c
d d
d
d d
c p d
i i i
o i
do fx do fx
do fx do fx
d
v canopies v d v
d
d d
d p c
d d d col
d c
d fx
d fx
d d d d dskyLightCol ddd d
sl d
sl fx sl sl sl
sl sl sllightCol sl sl
d
d d d p
c
p fx
name
d
fx
name d
p d c p
d
d dt d
d d dt
k sigI
c
k c c
d k
d k
d d k sigI k
rised d rise d rise k
rise k p dt
gatherd gather d gather d p dt
fxfx k
c
d d
d dt
sigI d
d d
d d d dd c p d dd
fxfx c c
t c c
d t
d t
d d t
sigI t
t wispd d wisp d wisp wisp p t dt
fxfx
d d sigI d d
i i d i
st di
st
st dt
v st st
st st st v dt
ststst st
st c p d st
glitterst glitterst glitter p st dt glitter
sm st st
sm smokest smokest smoke sm dt
st
st dt
st st dt
st st st st st st st
st st
f st st st st
st f st st
sl d
sl
sl dt
st sl
st st slst sl st st sl
sl sl sl
d
ddd d
d d d p
d
d dt
d d d d
d d d
v d
v
v d d p p
v
vd
vd
vd d d
vd d p d
v p
v d
cores glows
aA aB
time kA kB
n m
d
d
i i d n i
st di
st
fl st st st st st st
o n f st k st f fl
o st o st o st o st st st st
o col core k o col core k o col core k
o st st
n
vis d
vis i i m i
q i r01 dq
r01 d
ang dq d r01
ph dq tw time ph ph
o m kk vis tw tw ph ph
_aang r01 d dq d ang r01 ddd
o _a o _a o _a
o ph ph ph
w ph
o core w col w kk o core w col w kk o core w col w kk
m
q pops
q q
q dt
q q n
o n
o q o q o q o q
o q o q o q o q q
n
sgeo n
sprites n
n aA aB
kgeo m
skyStars m
m kA kB
`
vec3 ribbonShade(RibbonFrag r, out vec3 media, out float alpha, out float distortion) {
media = vec3(0.0); alpha = 0.0; distortion = 0.0;
float t = r.uv.x, y = r.uv.y, s = t * r.p2.y;
vec3 c = mix(uSfCore, uSfColor, smoothstep(0.02, 0.3, t));
c = mix(c, uSfGlow, smoothstep(0.4, 1.0, t));
float core = exp(-y * y * 9.0), soft = exp(-y * y * 2.2) * 0.3;
float fall = pow(1.0 - t, 2.4) + 0.25 * exp(-t * 30.0);
// glitter: sparse cells along the train flash on and off
float g = s * 6.0 + r.p2.x, cell = floor(g);
float on = step(0.76, hash11(cell * 1.37 + floor(uTime * 18.0 + hash11(cell + 3.1) * 9.0)));
float gx = (fract(g) - 0.5) * 3.0;
float sp = on * exp(-gx * gx) * exp(-y * y * 3.0) * (1.0 - t);
return r.color * (c * (core + soft) * fall + uSfCore * sp * 1.6);
}`
;
const
TRAIN_GLOW
=
TRAIN_UNIFORMS
+
/* glsl */
`
vec3 ribbonShade(RibbonFrag r, out vec3 media, out float alpha, out float distortion) {
media = vec3(0.0); alpha = 0.0; distortion = 0.0;
float t = r.uv.x, y = r.uv.y;
vec3 c = mix(uSfColor, uSfGlow, smoothstep(0.05, 0.8, t));
float g = max(exp(-y * y * 3.5) - 0.03, 0.0);
float k = 1.0 - t;
return r.color * c * g * k * k * k;
}`
;
// module scratch (nothing is allocated after create)
const
=
new
THREE.Vector3
(
)
,
=
new
THREE.Vector3
(
)
,
=
new
THREE.Vector3
(
)
;
const
UP
=
new
THREE.Vector3
(
0
,
1
,
0
)
;
const
=
THREE
.
MathUtils
.
smoothstep
;
const
inPool
=
(
x, z
)
=>
Math
.
abs
(
-
ARENA
.
pool
.
center
.
x
)
<
ARENA
.
pool
.
half
.
x
&&
Math
.
abs
(
-
ARENA
.
pool
.
center
.
y
)
<
ARENA
.
pool
.
half
.
y
;
export
default
{
id
:
'starfall'
,
name
:
'Starfall'
,
element
:
'arcane'
,
order
:
10
,
hue
:
'#ff4fd8'
,
shape
:
'area'
,
params
:
{
stars
:
18
,
radius
:
3.2
,
duration
:
1.6
,
height
:
8.5
,
angle
:
26
,
speed
:
30
,
trail
:
6
,
size
:
1
,
sparkles
:
1
,
intensity
:
1
,
sky
:
1
,
night
:
1
,
color
:
'#ff4fd8'
,
core
:
'#fff1fc'
,
glow
:
'#7a3dff'
,
}
,
ranges
:
{
stars
:
[
3
,
MAX_STARS
-
1
,
1
]
,
radius
:
[
1.5
,
6
,
0.01
]
,
duration
:
[
0.6
,
3
,
0.01
]
,
height
:
[
6
,
16
,
0.1
]
,
angle
:
[
0
,
50
,
0.5
]
,
speed
:
[
12
,
60
,
0.1
]
,
trail
:
[
1
,
9
,
0.01
]
,
size
:
[
0.4
,
2.5
,
0.01
]
,
sparkles
:
[
0
,
3
,
0.01
]
,
intensity
:
[
0.1
,
3
,
0.01
]
,
sky
:
[
0
,
2
,
0.01
]
,
night
:
[
0
,
2
,
0.01
]
,
}
,
presets
:
{
'meteor shower'
:
{
stars
:
24
,
duration
:
1.3
,
angle
:
38
,
speed
:
44
,
trail
:
6
,
size
:
0.75
}
,
'grand comets'
:
{
stars
:
6
,
size
:
1.7
,
trail
:
7.5
,
speed
:
24
,
duration
:
1.8
,
angle
:
18
}
,
twilight
:
{
color
:
'#b06cff'
,
core
:
'#f3e8ff'
,
glow
:
'#3b2dff'
,
sky
:
1.3
,
night
:
1.4
}
,
}
,
timing
:
{
charge
:
1.1
,
impact
:
2
,
linger
:
2.4
}
,
kinds
:
{
// stardust: thrown out by each impact, settles and twinkles out, paints glow where it lands
dust
:
{
style
:
'glow'
,
drag
:
1.8
,
gravity
:
3
,
curl
:
0.9
,
curlScale
:
0.5
,
restitution
:
0.2
,
friction
:
0.85
,
life
:
[
1.1
,
2.4
]
,
size
:
[
0.024
,
0.008
]
,
stretch
:
0.008
,
emissive
:
6
,
color
:
[
'#fff1fc'
,
'#ff4fd8'
]
,
alpha
:
[
1
,
0
]
,
fadeIn
:
0.02
,
fadeOut
:
0.55
,
paints
:
'glow'
,
paintAmount
:
0.05
}
,
// wisps of the night drifting up from the impact field after the barrage
// the bolide's persistent smoke train: lit dust that hangs in the air and twists (real fireballs leave one in daylight)
smoke
:
{
style
:
'media'
,
emissive
:
0
,
drag
:
2.2
,
buoyancy
:
0.08
,
curl
:
0.9
,
curlScale
:
0.22
,
life
:
[
2.6
,
4.4
]
,
size
:
[
0.16
,
0.85
]
,
sizePow
:
0.55
,
color
:
[
'#8c8494'
,
'#5d5866'
]
,
alpha
:
[
0.34
,
0
]
,
fadeIn
:
0.05
,
fadeOut
:
0.5
,
density
:
1.6
,
erosion
:
0.6
,
forceResponse
:
0.7
}
,
wisp
:
{
style
:
'glow'
,
drag
:
1.6
,
buoyancy
:
0.55
,
curl
:
1.3
,
curlScale
:
0.35
,
forceResponse
:
0.6
,
life
:
[
1.4
,
2.8
]
,
size
:
[
0.018
,
0.006
]
,
stretch
:
0.01
,
emissive
:
4
,
color
:
[
'#fff1fc'
,
'#7a3dff'
]
,
alpha
:
[
1
,
0
]
,
fadeIn
:
0.3
,
fadeOut
:
0.5
}
,
}
,
create
(
fx
)
{
const
S
=
this
,
P
=
.
particles
;
// the arcane family's own sparks and sparkles, by full name
const
=
P
.
emitter
(
'arcane.spark'
,
{
shape
:
'sphere'
,
radius
:
0.08
,
spread
:
3.2
,
radial
:
3.5
}
)
;
const
=
P
.
emitter
(
'arcane.sparkle'
,
{
shape
:
'sphere'
,
radius
:
0.06
,
spread
:
0.8
}
)
;
const
=
P
.
emitter
(
'arcane.sparkle'
,
{
shape
:
'shell'
,
radius
:
3
,
spread
:
0.2
,
radial
:
-
1.6
}
)
;
const
=
P
.
emitter
(
'arcane.mote'
,
{
shape
:
'ring'
,
radius
:
3
,
spread
:
0.2
}
)
;
const
=
P
.
emitter
(
'starfall.dust'
,
{
shape
:
'sphere'
,
radius
:
0.1
,
spread
:
2.2
,
radial
:
2.4
}
)
;
const
=
P
.
emitter
(
'starfall.wisp'
,
{
shape
:
'disk'
,
radius
:
3
,
spread
:
0.25
}
)
;
const
=
P
.
emitter
(
'starfall.smoke'
,
{
shape
:
'sphere'
,
radius
:
0.06
,
spread
:
0.25
}
)
;
// meteorite ejecta and the dust it raises: earth's own pebbles and dust, by full name
const
=
P
.
emitter
(
'earth.pebble'
,
{
shape
:
'sphere'
,
radius
:
0.12
,
spread
:
2.2
,
radial
:
4.5
}
)
;
const
=
P
.
emitter
(
'earth.dust'
,
{
shape
:
'sphere'
,
radius
:
0.25
,
spread
:
0.8
,
radial
:
1.6
}
)
;
// colours (linear), shared by reference with every material
const
=
new
THREE.Color
(
)
,
=
new
THREE.Color
(
)
,
=
new
THREE.Color
(
)
,
=
new
THREE.Color
(
)
,
=
new
THREE.Color
(
)
;
const
=
new
THREE.Vector3
(
)
,
=
new
THREE.Vector3
(
)
,
=
new
THREE.Vector3
(
)
;
let
=
''
,
=
''
,
=
''
;
function
syncColors
(
)
{
const
=
S
.
params
;
if
(
.
color
===
&&
.
core
===
&&
.
glow
===
)
return
;
=
.
color
;
=
.
core
;
=
.
glow
;
.
set
(
)
;
.
set
(
)
;
.
set
(
)
;
.
set
(
.
r
,
.
g
,
.
b
)
;
.
set
(
.
r
,
.
g
,
.
b
)
;
.
set
(
.
r
,
.
g
,
.
b
)
;
.
copy
(
)
.
lerp
(
,
0.35
)
;
.
copy
(
)
.
lerp
(
,
0.5
)
;
P
.
setKind
(
'starfall.dust'
,
{
color
:
[
,
]
}
)
;
P
.
setKind
(
'starfall.wisp'
,
{
color
:
[
,
]
}
)
;
}
// reusable option objects (the systems copy what they need)
const
SIG
=
{
pos
:
new
THREE.Vector3
(
)
,
normal
:
new
THREE.Vector3
(
0
,
1
,
0
)
,
radius
:
3
,
color
:
new
THREE.Color
(
)
,
intensity
:
0
,
reveal
:
0
,
rotation
:
0
,
style
:
'arcane'
,
seed
:
0
}
;
const
SHOCK
=
{
pos
:
new
THREE.Vector3
(
)
,
radius0
:
0.1
,
radius1
:
2
,
duration
:
0.4
,
thickness
:
0.3
,
distortion
:
0.03
,
color
:
,
intensity
:
1
,
ground
:
true
}
;
const
SPLAT
=
{
x
:
0
,
z
:
0
,
radius
:
1
,
glow
:
0
,
corruption
:
0
,
heat
:
0
,
char
:
0
,
crack
:
0
,
pattern
:
'ring'
,
seed
:
0
}
;
// --- canopies: two volume handles (two casts at once) ---