Agent Harness · VibeGit
Agent Harness Публичная копия обвязки агентной разработки: гейты, journeys, скиллы и шаблоны. Без ключей и личных данных.
agent-harness / tools / spells-assets / ue / vfx / Shockwaves.js 141 строк · изменён 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
import * as THREE from 'three' ;
import { U , COMMON_GLSL , FX_VERT_HEAD , FX_FRAG_HEAD , FX_OUT_GLSL , FX_BLENDING } from './common.js' ;
import { instanced } from './Ribbons.js' ;
const VERT
geo
geo
geo
geo n max
geo
geo
geo
max
index
s
x
x s x
x x s s s x
s pos
s radius0 radius1 duration thickness distortion intensity ground
color s color s
s
a0 a1 a2
top
s
o s
s
s dt
s s s
s a1 o
top s
x s s k x
e s k k k d s k x
a0 o s a0 o s a0 o s a0 o s
a1 o s s s x a1 o s x a1 o x
a2 o s e a2 o s e a2 o s e a2 o d
a a
top
top
=
`
in vec4 aS0; // centre, ground
in vec4 aS1; // radius, thickness, progress (< 0: dead), -
in vec4 aS2; // emission rgb, distortion (m), envelopes applied
out vec3 vWorld;
out float vViewZ;
flat out vec4 vS0;
flat out vec4 vS1;
flat out vec4 vS2;
flat out vec2 vCentre; // projected centre, fx pixels
void main() {
vS0 = aS0; vS1 = aS1; vS2 = aS2; vWorld = vec3(0.0); vViewZ = 1.0; vCentre = vec2(0.0);
vec3 c = aS0.xyz;
float R = aS1.x + 0.75 * aS1.y;
vec3 toC = c - cameraPosition;
float D = length(toC);
// ponytail: a camera inside a sphere shell just loses it (ground rings still draw)
if (aS1.z < 0.0 || (aS0.w < 0.5 && D < R * 1.05)) { gl_Position = vec4(2.0, 2.0, 2.0, 1.0); return; }
vec3 p;
if (aS0.w > 0.5) p = c + vec3(position.x * R, 0.03, position.y * R);
else {
vec3 f = toC / D, r = normalize(cross(f, abs(f.y) < 0.99 ? vec3(0.0, 1.0, 0.0) : vec3(1.0, 0.0, 0.0))), u = cross(r, f);
p = c + (r * position.x + u * position.y) * (R / sqrt(1.0 - (R / D) * (R / D)));
}
vWorld = p;
vec4 cc = projectionMatrix * viewMatrix * vec4(c, 1.0);
vCentre = (cc.xy / cc.w * 0.5 + 0.5) * uFxResolution;
vec4 view = viewMatrix * vec4(p, 1.0);
vViewZ = -view.z;
gl_Position = projectionMatrix * view;
} `
;
const
FRAG
=
`
uniform mat4 projectionMatrix;
in vec3 vWorld;
in float vViewZ;
flat in vec4 vS0;
flat in vec4 vS1;
flat in vec4 vS2;
flat in vec2 vCentre;
void main() {
vec3 c = vS0.xyz;
float r = vS1.x, th = vS1.y, prof;
if (vS0.w > 0.5) {
// sharp leading edge, soft wake behind it
float x = (length(vWorld.xz - c.xz) - r) / (0.5 * th);
prof = exp(-x * x * (x > 0.0 ? 6.0 : 0.8));
} else {
vec3 rd = normalize(vWorld - cameraPosition), oc = c - cameraPosition;
float tc = dot(oc, rd), rho2 = max(dot(oc, oc) - tc * tc, 0.0);
float ro = r + 0.5 * th, ri = max(r - 0.5 * th, 0.0);
float chord = sqrt(max(ro * ro - rho2, 0.0)) - sqrt(max(ri * ri - rho2, 0.0));
prof = chord / sqrt(max(ro * ro - ri * ri, 1e-6));
}
if (prof < 1e-3) discard;
vec2 dir = gl_FragCoord.xy - vCentre;
dir = dot(dir, dir) > 1e-6 ? normalize(dir) : vec2(0.0);
float h = 0.5 * projectionMatrix[1][1] / max(vViewZ, 1e-3);
float s = softFade(vViewZ, 0.3) * prof;
// sample nearer the centre: the background bulges outward under the rim
vec2 dist = -dir * vec2(h * uFxResolution.y / uFxResolution.x, h) * vS2.w * s;
// emission hugs the rim (seen through, the shell's two walls would otherwise glow as a dome)
float p2 = prof * prof;
fxOut(vec3(0.0), 0.0, vS2.rgb * p2 * p2 * softFade(vViewZ, 0.3), dist, vViewZ);
} `
;
export
class
Shockwaves
{
constructor
(
{ max = 16 } = { }
)
{
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
]
)
;
this
.
attrs
=
[
'aS0'
,
'aS1'
,
'aS2'
]
.
map
(
(
n
)
=>
instanced
(
,
,
)
)
;
.
instanceCount
=
0
;
this
.
geometry
=
;
this
.
uniforms
=
{
...
U
}
;
this
.
mesh
=
new
THREE. Mesh
(
,
new
THREE. RawShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
uniforms
:
this
.
uniforms
,
...
FX_BLENDING
,
side
:
THREE
.
DoubleSide
,
vertexShader
:
FX_VERT_HEAD
+
COMMON_GLSL
+
VERT
,
fragmentShader
:
FX_FRAG_HEAD
+
COMMON_GLSL
+
FX_OUT_GLSL
+
FRAG
,
}
)
)
;
this
.
mesh
.
frustumCulled
=
false
;
this
.
mesh
.
visible
=
false
;
this
.
slots
=
Array
.
from
(
{
length
:
}
,
(
_, index
)
=>
(
{
,
active
:
false
,
age
:
0
,
pos
:
new
THREE. Vector3
(
)
,
radius0
:
0.2
,
radius1
:
6
,
duration
:
0.6
,
thickness
:
0.6
,
distortion
:
0.12
,
color
:
new
THREE. Color
(
1
,
1
,
1
)
,
intensity
:
0
,
ground
:
false
,
}
)
)
;
}
spawn
(
{ pos, radius0 = 0.2 , radius1 = 6 , duration = 0.6 , thickness = 0.6 , distortion = 0.12 , color, intensity = 0 , ground = false }
)
{
let
=
this
.
slots
[
0
]
;
for
(
const
of
this
.
slots
)
{
if
(
!
.
active
)
{
=
;
break
;
}
if
(
.
age
/
.
duration
>
.
age
/
.
duration
)
=
;
}
.
pos
.
copy
(
)
;
Object
.
assign
(
,
{
active
:
true
,
age
:
0
,
,
,
,
,
,
,
}
)
;
if
(
)
.
color
.
copy
(
)
;
else
.
color
.
setRGB
(
1
,
1
,
1
)
;
return
;
}
update
(
dt
)
{
const
=
this
.
attrs
[
0
]
.
array
,
=
this
.
attrs
[
1
]
.
array
,
=
this
.
attrs
[
2
]
.
array
;
let
=
0
;
for
(
const
of
this
.
slots
)
{
const
=
.
index
*
4
;
if
(
.
active
)
{
.
age
+=
;
if
(
.
age
>=
.
duration
)
.
active
=
false
;
}
if
(
!
.
active
)
{
[
+
2
]
=
-
1
;
continue
;
}
=
.
index
+
1
;
const
=
.
age
/
.
duration
,
=
1
-
;
const
=
.
intensity
*
*
*
,
=
.
distortion
*
Math
.
pow
(
,
1.5
)
*
Math
.
min
(
1
,
/
0.05
)
;
[
]
=
.
pos
.
x
;
[
+
1
]
=
.
pos
.
y
;
[
+
2
]
=
.
pos
.
z
;
[
+
3
]
=
.
ground
?
1
:
0
;
[
]
=
.
radius0
+
(
.
radius1
-
.
radius0
)
*
Math
.
pow
(
,
0.4
)
;
[
+
1
]
=
.
thickness
*
(
0.5
+
0.5
*
)
;
[
+
2
]
=
;
[
]
=
.
color
.
r
*
;
[
+
1
]
=
.
color
.
g
*
;
[
+
2
]
=
.
color
.
b
*
;
[
+
3
]
=
;
}
for
(
const
of
this
.
attrs
)
.
needsUpdate
=
true
;
this
.
geometry
.
instanceCount
=
;
this
.
mesh
.
visible
=
>
0
;
}
}