reze-engine 0.68.29 → 0.68.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +2 -1
- package/dist/graph/slots.d.ts.map +1 -1
- package/dist/graph/slots.js +6 -1
- package/dist/jelly-eyes.d.ts +4 -0
- package/dist/jelly-eyes.d.ts.map +1 -1
- package/dist/jelly-eyes.js +30 -5
- package/dist/shaders/materials/common.d.ts.map +1 -1
- package/dist/shaders/materials/common.js +0 -13
- package/dist/shaders/passes/depth-prepass.d.ts.map +1 -1
- package/dist/shaders/passes/depth-prepass.js +1 -5
- package/dist/shaders/passes/outline.d.ts.map +1 -1
- package/dist/shaders/passes/outline.js +1 -5
- package/dist/shaders/passes/shadow.d.ts +1 -1
- package/dist/shaders/passes/shadow.d.ts.map +1 -1
- package/dist/shaders/passes/shadow.js +3 -6
- package/package.json +1 -1
- package/src/engine.ts +2 -1
- package/src/graph/slots.ts +6 -1
- package/src/jelly-eyes.ts +39 -5
- package/src/shaders/materials/common.ts +0 -13
- package/src/shaders/passes/depth-prepass.ts +1 -5
- package/src/shaders/passes/outline.ts +1 -5
- package/src/shaders/passes/shadow.ts +3 -6
- package/dist/_dbg-loader.mjs +0 -1100
|
@@ -34,11 +34,9 @@ ${JELLY_VERTEX_WGSL}
|
|
|
34
34
|
struct VSOut {
|
|
35
35
|
@builtin(position) position: vec4f,
|
|
36
36
|
@location(0) uv: vec2f,
|
|
37
|
-
/** Bind-pose position, for the dissolve test — object space, as everywhere.
|
|
37
|
+
/** Bind-pose position, for the dissolve test — object space, as everywhere.
|
|
38
|
+
* A flake that is gone must stop casting. */
|
|
38
39
|
@location(1) restPos: vec3f,
|
|
39
|
-
/** The triangle's own threshold, flat — see the material VertexOutput. A
|
|
40
|
-
* face that is gone must stop casting, and stop as a whole face. */
|
|
41
|
-
@location(2) @interpolate(flat) faceT: f32,
|
|
42
40
|
};
|
|
43
41
|
|
|
44
42
|
@vertex fn vs(@location(0) position: vec3f, @location(1) normal: vec3f, @location(2) uv: vec2f,
|
|
@@ -54,7 +52,6 @@ struct VSOut {
|
|
|
54
52
|
out.position = lp.viewProj * vec4f(sp.xyz, 1.0);
|
|
55
53
|
out.uv = uv;
|
|
56
54
|
out.restPos = position;
|
|
57
|
-
out.faceT = rz_dissolve_threshold(position);
|
|
58
55
|
return out;
|
|
59
56
|
}
|
|
60
57
|
|
|
@@ -64,6 +61,6 @@ struct VSOut {
|
|
|
64
61
|
// The dissolve, run as the colour pass runs it. A flake that is gone stops
|
|
65
62
|
// casting: without this she leaves a whole shadow standing on the floor while
|
|
66
63
|
// her body is in the air.
|
|
67
|
-
if (material.dissolve < 0.9995 && in.
|
|
64
|
+
if (material.dissolve < 0.9995 && rz_dissolve_threshold(in.restPos) > material.dissolve) { discard; }
|
|
68
65
|
}
|
|
69
66
|
`;
|
package/package.json
CHANGED
package/src/engine.ts
CHANGED
|
@@ -14105,6 +14105,7 @@ export class Engine {
|
|
|
14105
14105
|
if (inst.jellyEyes) {
|
|
14106
14106
|
inst.jellyEyes.strength = clampStrength(options.strength)
|
|
14107
14107
|
inst.jellyEyes.idle = options.idle ?? true
|
|
14108
|
+
inst.jellyEyes.motion = options.motion ?? true
|
|
14108
14109
|
}
|
|
14109
14110
|
else inst.jellyEyes = new JellyEyes(inst.model, options)
|
|
14110
14111
|
return true
|
|
@@ -14112,7 +14113,7 @@ export class Engine {
|
|
|
14112
14113
|
|
|
14113
14114
|
getModelJellyEyes(modelName: string): Required<JellyEyeOptions> | null {
|
|
14114
14115
|
const jelly = this.modelInstances.get(modelName)?.jellyEyes
|
|
14115
|
-
return jelly ? { strength: jelly.strength, idle: jelly.idle } : null
|
|
14116
|
+
return jelly ? { strength: jelly.strength, idle: jelly.idle, motion: jelly.motion } : null
|
|
14116
14117
|
}
|
|
14117
14118
|
|
|
14118
14119
|
getModelCastShadow(modelName: string): boolean {
|
package/src/graph/slots.ts
CHANGED
|
@@ -126,7 +126,12 @@ ${discard}
|
|
|
126
126
|
// as burning away rather than as a stencil moving over her.
|
|
127
127
|
var rz_burn = 0.0;
|
|
128
128
|
if (material.dissolve < 0.9995) {
|
|
129
|
-
|
|
129
|
+
// PER FRAGMENT, from the bind-pose position: the pieces are the noise's,
|
|
130
|
+
// grit inside clumps, never the mesh's triangles, so a large face comes
|
|
131
|
+
// apart as finely as a small one. The prepass, the shadow map and the
|
|
132
|
+
// outline hull run the same function on the same interpolated input, so
|
|
133
|
+
// every pass agrees about which flakes are gone.
|
|
134
|
+
let rz_t = rz_dissolve_threshold(input.restPos);
|
|
130
135
|
if (rz_t > material.dissolve) { discard; }
|
|
131
136
|
// Put OUT as the last of her goes. Near zero the front is wider than what
|
|
132
137
|
// is left of the surface, so every surviving fragment sits inside it and
|
package/src/jelly-eyes.ts
CHANGED
|
@@ -31,6 +31,9 @@ export interface JellyEyeOptions {
|
|
|
31
31
|
/** The idle taps: a ripple every 4–8 s while nothing else moves them.
|
|
32
32
|
* Default true; false leaves only what her blinks and motion set off. */
|
|
33
33
|
idle?: boolean
|
|
34
|
+
/** Whether her head's motion knocks them: a turn, a bob, a step. Default
|
|
35
|
+
* true; false leaves only her blinks and the idle taps. */
|
|
36
|
+
motion?: boolean
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
// The closing morphs, by the names MMD, VRoid and the usual converters give
|
|
@@ -107,6 +110,15 @@ const ROLL_ZETA = Math.LN2 / HALF_LIFE / (2 * Math.PI * ROLL_HZ)
|
|
|
107
110
|
// How much of the spring's swing about the expression angle shows: a
|
|
108
111
|
// twenty-fifth of an iris radius past centre after a blink.
|
|
109
112
|
const ROLL_SWING = 0.25
|
|
113
|
+
// How long a held expression takes to stop pressing and rolling the iris, in
|
|
114
|
+
// seconds: the press and the roll answer the CHANGE of the lids, as the MME's
|
|
115
|
+
// spring does, never where they sit. A smile or a はぅ held through a chorus
|
|
116
|
+
// once kept the iris a fifth shorter and rolled down for as long as it held —
|
|
117
|
+
// on a squint that leaves the eyes open, the irises sank to the bottom of the
|
|
118
|
+
// eyes — and leftover weights of a few hundredths, summed, kept a neutral face
|
|
119
|
+
// pressed for good. A blink's own close is far quicker than this, so it still
|
|
120
|
+
// presses and rolls in full.
|
|
121
|
+
const HOLD_S = 0.3
|
|
110
122
|
const PUSH_ELASTIC = 0.04
|
|
111
123
|
// A highlight sheet by name, for rigs that keep it on its own material.
|
|
112
124
|
const HIGHLIGHT = /ハイライト|ハイライト|高光|highlight|hilight|(^|[^a-z])hl([^a-z]|$)/i
|
|
@@ -196,6 +208,10 @@ interface EyeState {
|
|
|
196
208
|
// The roll (degrees) and its velocity, chasing the expressions' angle.
|
|
197
209
|
roll: number
|
|
198
210
|
rollV: number
|
|
211
|
+
// Where the lids and the expressions' angle have been HELD: followers HOLD_S
|
|
212
|
+
// behind them. The press and the roll are what is left past them.
|
|
213
|
+
closureHeld: number
|
|
214
|
+
rollHeld: number
|
|
199
215
|
pulseV: number
|
|
200
216
|
}
|
|
201
217
|
|
|
@@ -234,6 +250,8 @@ interface MorphShift {
|
|
|
234
250
|
|
|
235
251
|
const newState = (): EyeState => ({
|
|
236
252
|
closure: 0,
|
|
253
|
+
closureHeld: 0,
|
|
254
|
+
rollHeld: 0,
|
|
237
255
|
prev: 0,
|
|
238
256
|
speed: 0,
|
|
239
257
|
trend: 0,
|
|
@@ -254,6 +272,7 @@ const newState = (): EyeState => ({
|
|
|
254
272
|
export class JellyEyes {
|
|
255
273
|
strength: number
|
|
256
274
|
idle: boolean
|
|
275
|
+
motion: boolean
|
|
257
276
|
// Scene time stepped so far, and the idle taps: how many, and when the next.
|
|
258
277
|
private clock = 0
|
|
259
278
|
private taps = 0
|
|
@@ -282,6 +301,7 @@ export class JellyEyes {
|
|
|
282
301
|
constructor(model: Model, options: JellyEyeOptions) {
|
|
283
302
|
this.strength = clampStrength(options.strength)
|
|
284
303
|
this.idle = options.idle ?? true
|
|
304
|
+
this.motion = options.motion ?? true
|
|
285
305
|
const bones = model.getSkeleton().bones
|
|
286
306
|
const index = (name: string) => bones.findIndex((b) => b.name === name)
|
|
287
307
|
const both = index("両目")
|
|
@@ -354,7 +374,8 @@ export class JellyEyes {
|
|
|
354
374
|
// Only her motion — the head turning and moving (the inertia) — and her
|
|
355
375
|
// blinks do.
|
|
356
376
|
look(head, null, s.look)
|
|
357
|
-
const
|
|
377
|
+
const moved = this.motion ? Math.tanh(Math.hypot(...this.offset(s, e)) / PULSE_REF) : 0
|
|
378
|
+
const knock = seek ? 0 : Math.max(this.tapKnock, moved)
|
|
358
379
|
const squashTarget = MOTION_SQUASH * knock
|
|
359
380
|
if (seek) {
|
|
360
381
|
// Landing on a pose is no blink: the spring rests where it lands.
|
|
@@ -367,11 +388,18 @@ export class JellyEyes {
|
|
|
367
388
|
s.lag[1] = s.look[1]
|
|
368
389
|
s.lagV[0] = s.lagV[1] = 0
|
|
369
390
|
s.pulse = s.pulseV = 0
|
|
370
|
-
s.
|
|
391
|
+
s.closureHeld = s.closure
|
|
392
|
+
s.rollHeld = this.roll[e]
|
|
393
|
+
s.roll = 0
|
|
371
394
|
s.rollV = 0
|
|
372
395
|
continue
|
|
373
396
|
}
|
|
374
397
|
blink(s, dt)
|
|
398
|
+
if (dt > 0) {
|
|
399
|
+
const k = 1 - Math.exp(-dt / HOLD_S)
|
|
400
|
+
s.closureHeld += (s.closure - s.closureHeld) * k
|
|
401
|
+
s.rollHeld += (this.roll[e] - s.rollHeld) * k
|
|
402
|
+
}
|
|
375
403
|
const steps = Math.ceil(dt / SUBSTEP)
|
|
376
404
|
const h = steps > 0 ? dt / steps : 0
|
|
377
405
|
const pulseTarget = PULSE_MAX * knock
|
|
@@ -380,7 +408,7 @@ export class JellyEyes {
|
|
|
380
408
|
s.pulse += h * s.pulseV
|
|
381
409
|
s.squashV += h * spring(s.squash - squashTarget, s.squashV, SQUASH_HZ, SQUASH_ZETA)
|
|
382
410
|
s.squash += h * s.squashV
|
|
383
|
-
s.rollV += h * spring(s.roll - this.roll[e], s.rollV, ROLL_HZ, ROLL_ZETA)
|
|
411
|
+
s.rollV += h * spring(s.roll - pressedRoll(this.roll[e], s.rollHeld), s.rollV, ROLL_HZ, ROLL_ZETA)
|
|
384
412
|
s.roll += h * s.rollV
|
|
385
413
|
for (let k = 0; k < 2; k++) {
|
|
386
414
|
s.lagV[k] += h * spring(s.lag[k] - s.look[k], s.lagV[k], LAG_HZ, LAG_ZETA)
|
|
@@ -414,7 +442,7 @@ export class JellyEyes {
|
|
|
414
442
|
const vn = s.v / omega
|
|
415
443
|
const gain = (k: 0 | 1) => SCALE_GAIN[k] * (x >= 0 ? 1 : REBOUND[k])
|
|
416
444
|
const kx = (1 + x * gain(0)) * (1 - 0.8 * s.squash + pulse)
|
|
417
|
-
const ky = (1 + x * gain(1)) * (1 - SQUEEZE_Y * s.closure) * (1 - s.squash + pulse)
|
|
445
|
+
const ky = (1 + x * gain(1)) * (1 - SQUEEZE_Y * Math.max(0, s.closure - s.closureHeld)) * (1 - s.squash + pulse)
|
|
418
446
|
o.set([rest.radius[0], rest.radius[1], s.closure, this.eyeBones[e]], 56 + e * 4)
|
|
419
447
|
// [4]/[5]: scale across and down, the iris's twist, the highlight's turn.
|
|
420
448
|
o.set([by(kx, 0.78, 1.25), by(ky, 0.7, 1.08), (x * TWIST_POS + vn * TWIST_VEL) * DEG * g, vn * HL_TURN * DEG * g], 64 + e * 4)
|
|
@@ -434,7 +462,7 @@ export class JellyEyes {
|
|
|
434
462
|
// [8]/[9]: the roll's pivot and angle; [10]/[11]: the highlight's own
|
|
435
463
|
// scale, and how far the iris comes forward (bind units).
|
|
436
464
|
const pivot = rest.pivot
|
|
437
|
-
o.set(pivot ? [pivot[0], pivot[1], pivot[2], (this.roll[e] + (s.roll - this.roll[e]) * ROLL_SWING) * DEG * g] : [0, 0, 0, 0], 80 + e * 4)
|
|
465
|
+
o.set(pivot ? [pivot[0], pivot[1], pivot[2], (pressedRoll(this.roll[e], s.rollHeld) + (s.roll - pressedRoll(this.roll[e], s.rollHeld)) * ROLL_SWING) * DEG * g] : [0, 0, 0, 0], 80 + e * 4)
|
|
438
466
|
const hs = (k: 0 | 1) => Math.max(HL_SCALE_MIN, Math.min(HL_SCALE_MAX, 1 + x * HL_SCALE[k] * g))
|
|
439
467
|
o.set([hs(0), hs(1), Math.min(Math.abs(x), SPRING_LIMIT) * PUSH_ELASTIC * r * g, 0], 88 + e * 4)
|
|
440
468
|
}
|
|
@@ -493,6 +521,12 @@ export class JellyEyes {
|
|
|
493
521
|
}
|
|
494
522
|
}
|
|
495
523
|
|
|
524
|
+
/** The part of an expression's roll past where it has been held: the full
|
|
525
|
+
* angle while it arrives, nothing once it stays, nothing as it leaves. */
|
|
526
|
+
function pressedRoll(angle: number, held: number): number {
|
|
527
|
+
return Math.sign(angle) * Math.max(0, Math.abs(angle) - Math.abs(held))
|
|
528
|
+
}
|
|
529
|
+
|
|
496
530
|
/** Zero jelly[0..11] — strength 0 is what the shader reads as off. */
|
|
497
531
|
export function clearJellyEyes(o: Float32Array): void {
|
|
498
532
|
o.fill(0, 48, 96)
|
|
@@ -191,18 +191,6 @@ struct VertexOutput {
|
|
|
191
191
|
// At rest skinMats are identity so restPos == worldPos, which is why existing noise-
|
|
192
192
|
// scale constants stay valid without retuning.
|
|
193
193
|
@location(3) restPos: vec3f,
|
|
194
|
-
/**
|
|
195
|
-
* This TRIANGLE's dissolve threshold.
|
|
196
|
-
*
|
|
197
|
-
* FLAT, so every fragment of a face shares the provoking vertex's value and
|
|
198
|
-
* the face goes as a unit — the mesh comes apart in triangles that light and
|
|
199
|
-
* leave in turn, rather than in a scatter that crosses them. Computed in the
|
|
200
|
-
* vertex stage from the bind-pose attribute, which is what lets the depth
|
|
201
|
-
* prepass, the shadow map and the outline hull reach the same number for the
|
|
202
|
-
* same face: one function, one input, one provoking vertex, one answer. They
|
|
203
|
-
* must agree — a pass that disagrees punches holes through her.
|
|
204
|
-
*/
|
|
205
|
-
@location(4) @interpolate(flat) faceT: f32,
|
|
206
194
|
/** The scene fog's two amounts, computed PER VERTEX as the game does — see
|
|
207
195
|
* Engine.setSceneFog — and interpolated across the face. */
|
|
208
196
|
@location(5) fog: vec2f,
|
|
@@ -484,7 +472,6 @@ const COMMON_VS_WGSL = /* wgsl */ `
|
|
|
484
472
|
output.uv = uv;
|
|
485
473
|
output.worldPos = skinnedPos.xyz;
|
|
486
474
|
output.restPos = position;
|
|
487
|
-
output.faceT = rz_dissolve_threshold(position);
|
|
488
475
|
let viewZ = (camera.view * vec4f(skinnedPos.xyz, 1.0)).z;
|
|
489
476
|
output.fog = vec2f(
|
|
490
477
|
_rzFogAmount(viewZ, skinnedPos.y, light.fog[0], light.fog[1]),
|
|
@@ -69,9 +69,6 @@ struct VSOut {
|
|
|
69
69
|
// The bind-pose position, carried for one reason: the dissolve test below has
|
|
70
70
|
// to be the SAME test the colour pass runs, and that one is in object space.
|
|
71
71
|
@location(1) restPos: vec3f,
|
|
72
|
-
/** The triangle's own threshold, flat — see the material VertexOutput. This
|
|
73
|
-
* pass must throw away exactly the faces the colour pass does. */
|
|
74
|
-
@location(2) @interpolate(flat) faceT: f32,
|
|
75
72
|
};
|
|
76
73
|
|
|
77
74
|
@vertex fn vs(
|
|
@@ -94,7 +91,6 @@ struct VSOut {
|
|
|
94
91
|
o.position = camera.projection * camera.view * vec4f(skinned.xyz, 1.0);
|
|
95
92
|
o.uv = uv;
|
|
96
93
|
o.restPos = position;
|
|
97
|
-
o.faceT = rz_dissolve_threshold(position);
|
|
98
94
|
return o;
|
|
99
95
|
}
|
|
100
96
|
|
|
@@ -121,7 +117,7 @@ override CUTOFF: f32 = 0.5;
|
|
|
121
117
|
// the colour pass throws away would punch holes that occlude the floor behind
|
|
122
118
|
// her: you would see sky through her, which is the failure this line exists
|
|
123
119
|
// to prevent.
|
|
124
|
-
if (material.dissolve < 0.9995 && in.
|
|
120
|
+
if (material.dissolve < 0.9995 && rz_dissolve_threshold(in.restPos) > material.dissolve) { discard; }
|
|
125
121
|
var out: PrepassOut;
|
|
126
122
|
out.color = vec4f(0.0);
|
|
127
123
|
out.mask = vec4f(0.0);
|
|
@@ -104,9 +104,6 @@ struct VertexOutput {
|
|
|
104
104
|
* the depth prepass measure against, so all three agree about which flakes
|
|
105
105
|
* are gone. */
|
|
106
106
|
@location(1) restPos: vec3f,
|
|
107
|
-
/** The triangle's own threshold, flat — see the material VertexOutput. The
|
|
108
|
-
* hull traces the body's faces, so it has to lose the same ones. */
|
|
109
|
-
@location(2) @interpolate(flat) faceT: f32,
|
|
110
107
|
/** How much of a pixel-wide line this one really is (1 = all of it): a line
|
|
111
108
|
* held at the minimum width fades by what it was short. */
|
|
112
109
|
@location(3) coverage: f32,
|
|
@@ -246,7 +243,6 @@ fn safe_normal2(v: vec2f) -> vec2f {
|
|
|
246
243
|
output.position = vec4f(clipPos.xy + ndc * w, clipPos.z, clipPos.w);
|
|
247
244
|
output.uv = uv;
|
|
248
245
|
output.restPos = position;
|
|
249
|
-
output.faceT = rz_dissolve_threshold(position);
|
|
250
246
|
return output;
|
|
251
247
|
}
|
|
252
248
|
|
|
@@ -272,7 +268,7 @@ ${sceneFsOutWgsl({ name: "FSOut", aux: "mask" })}
|
|
|
272
268
|
// The same test the colour pass and the depth prepass run, against the same
|
|
273
269
|
// bind-pose position — three passes, one rule, or they disagree about which
|
|
274
270
|
// pieces are still there.
|
|
275
|
-
if (material.dissolve < 0.9995 && input.
|
|
271
|
+
if (material.dissolve < 0.9995 && rz_dissolve_threshold(input.restPos) > material.dissolve) { discard; }
|
|
276
272
|
let tex = textureSample(diffuseTexture, edgeSampler, input.uv);
|
|
277
273
|
let texA = tex.a;
|
|
278
274
|
if (texA < 0.05) {
|
|
@@ -36,11 +36,9 @@ ${JELLY_VERTEX_WGSL}
|
|
|
36
36
|
struct VSOut {
|
|
37
37
|
@builtin(position) position: vec4f,
|
|
38
38
|
@location(0) uv: vec2f,
|
|
39
|
-
/** Bind-pose position, for the dissolve test — object space, as everywhere.
|
|
39
|
+
/** Bind-pose position, for the dissolve test — object space, as everywhere.
|
|
40
|
+
* A flake that is gone must stop casting. */
|
|
40
41
|
@location(1) restPos: vec3f,
|
|
41
|
-
/** The triangle's own threshold, flat — see the material VertexOutput. A
|
|
42
|
-
* face that is gone must stop casting, and stop as a whole face. */
|
|
43
|
-
@location(2) @interpolate(flat) faceT: f32,
|
|
44
42
|
};
|
|
45
43
|
|
|
46
44
|
@vertex fn vs(@location(0) position: vec3f, @location(1) normal: vec3f, @location(2) uv: vec2f,
|
|
@@ -56,7 +54,6 @@ struct VSOut {
|
|
|
56
54
|
out.position = lp.viewProj * vec4f(sp.xyz, 1.0);
|
|
57
55
|
out.uv = uv;
|
|
58
56
|
out.restPos = position;
|
|
59
|
-
out.faceT = rz_dissolve_threshold(position);
|
|
60
57
|
return out;
|
|
61
58
|
}
|
|
62
59
|
|
|
@@ -66,6 +63,6 @@ struct VSOut {
|
|
|
66
63
|
// The dissolve, run as the colour pass runs it. A flake that is gone stops
|
|
67
64
|
// casting: without this she leaves a whole shadow standing on the floor while
|
|
68
65
|
// her body is in the air.
|
|
69
|
-
if (material.dissolve < 0.9995 && in.
|
|
66
|
+
if (material.dissolve < 0.9995 && rz_dissolve_threshold(in.restPos) > material.dissolve) { discard; }
|
|
70
67
|
}
|
|
71
68
|
`
|