reze-engine 0.69.9 → 0.70.0
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/camera-mount.d.ts +57 -0
- package/dist/camera-mount.d.ts.map +1 -0
- package/dist/camera-mount.js +249 -0
- package/dist/camera.d.ts +11 -0
- package/dist/camera.d.ts.map +1 -1
- package/dist/camera.js +31 -7
- package/dist/engine.d.ts +94 -2
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +395 -9
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/model.d.ts +35 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +170 -0
- package/dist/shaders/passes/cull.d.ts +1 -1
- package/dist/shaders/passes/cull.d.ts.map +1 -1
- package/dist/shaders/passes/cull.js +4 -1
- package/dist/shaders/passes/motion-blur.d.ts +35 -0
- package/dist/shaders/passes/motion-blur.d.ts.map +1 -0
- package/dist/shaders/passes/motion-blur.js +166 -0
- package/package.json +1 -1
- package/src/camera-mount.ts +281 -0
- package/src/camera.ts +27 -4
- package/src/engine.ts +414 -10
- package/src/index.ts +3 -1
- package/src/model.ts +193 -0
- package/src/shaders/passes/cull.ts +4 -1
- package/src/shaders/passes/motion-blur.ts +171 -0
package/dist/engine.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Camera } from "./camera";
|
|
2
|
+
import { CameraMount, headMaterials } from "./camera-mount";
|
|
2
3
|
import { EFFECT_SUBJECT_VEC4S } from "./shaders/cast-layout";
|
|
3
4
|
import { decodeDds, isDds } from "./dds-loader";
|
|
4
5
|
import { Mat4, Quat, Vec3 } from "./math";
|
|
@@ -70,6 +71,7 @@ import { STOCKINGS_GRAPH } from "./graph/presets/stockings";
|
|
|
70
71
|
import { METAL_GRAPH } from "./graph/presets/metal";
|
|
71
72
|
import { CLOTH_SMOOTH_GRAPH } from "./graph/presets/cloth_smooth";
|
|
72
73
|
import { CLOTH_ROUGH_GRAPH } from "./graph/presets/cloth_rough";
|
|
74
|
+
import { MOTION_BLUR_UNIFORM_FLOATS, MOTION_BLUR_WGSL, MOTION_VELOCITY_FORMAT, motionVelocityWgsl, } from "./shaders/passes/motion-blur";
|
|
73
75
|
/** Grow sphere `s` (x, y, z, radius; radius 0 = empty) to hold another: the
|
|
74
76
|
* standard union, keeping the larger if one contains the other, else growing
|
|
75
77
|
* along the line between the centres. */
|
|
@@ -1406,6 +1408,8 @@ export class Engine {
|
|
|
1406
1408
|
this.cameraFollowYaw = 0;
|
|
1407
1409
|
this.cameraFollowPitch = 0;
|
|
1408
1410
|
this.cameraTargetOffset = new Vec3(0, 0, 0);
|
|
1411
|
+
/** The camera on a bone (setCameraMount), and whose rig it rides. */
|
|
1412
|
+
this.cameraMount = null;
|
|
1409
1413
|
this.lastFrameTime = performance.now();
|
|
1410
1414
|
this.frameIntervals = new Float32Array(Engine.STATS_WINDOW);
|
|
1411
1415
|
this.frameIntervalWrite = 0;
|
|
@@ -1820,6 +1824,29 @@ export class Engine {
|
|
|
1820
1824
|
this.gizmoDrag = null;
|
|
1821
1825
|
this.camera?.setInputLocked(false);
|
|
1822
1826
|
};
|
|
1827
|
+
/** See setTimeScale. */
|
|
1828
|
+
this.timeScale = 1;
|
|
1829
|
+
// ─── Motion blur (shaders/passes/motion-blur.ts) ───────────────────────
|
|
1830
|
+
this.motionBlur = null;
|
|
1831
|
+
this.mbVelocityPipeline = null;
|
|
1832
|
+
this.mbVelocityPending = false;
|
|
1833
|
+
this.mbGatherPipeline = null;
|
|
1834
|
+
this.mbFrameLayout = null;
|
|
1835
|
+
this.mbInstanceLayout = null;
|
|
1836
|
+
this.mbFrameBindGroup = null;
|
|
1837
|
+
this.mbPrevCameraBuffer = null;
|
|
1838
|
+
this.mbUniformBuffer = null;
|
|
1839
|
+
this.mbUniformData = new Float32Array(MOTION_BLUR_UNIFORM_FLOATS);
|
|
1840
|
+
this.mbVelocityMs = null;
|
|
1841
|
+
this.mbVelocity = null;
|
|
1842
|
+
this.mbScratch = null;
|
|
1843
|
+
this.mbGatherBindGroup = null;
|
|
1844
|
+
this.mbGatherDepthView = null;
|
|
1845
|
+
this.mbSampler = null;
|
|
1846
|
+
/** Last frame's camera view-projection, or null after a cut or on the first frame. */
|
|
1847
|
+
this.mbPrevViewProj = null;
|
|
1848
|
+
/** Per model: last frame's skin matrices on the GPU, and the CPU copy they came from. */
|
|
1849
|
+
this.mbInstances = new WeakMap();
|
|
1823
1850
|
/** Models this wrote a dissolve onto last frame, so one nothing asks for any
|
|
1824
1851
|
* more comes back whole instead of holding wherever it was left. */
|
|
1825
1852
|
this.dissolveTouched = new Set();
|
|
@@ -8291,7 +8318,8 @@ export class Engine {
|
|
|
8291
8318
|
label: "HDR resolve target",
|
|
8292
8319
|
size: [width, height],
|
|
8293
8320
|
format: this.hdrFormat,
|
|
8294
|
-
|
|
8321
|
+
// COPY_DST: motion blur writes its gather back here.
|
|
8322
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST,
|
|
8295
8323
|
});
|
|
8296
8324
|
// The id attachment. Multisampled like the rest of the pass, and with NO
|
|
8297
8325
|
// resolve texture beside it: resolving averages, and the average of two
|
|
@@ -9351,6 +9379,67 @@ export class Engine {
|
|
|
9351
9379
|
o.x = ox * c + o.z * sn;
|
|
9352
9380
|
o.z = -ox * sn + o.z * c;
|
|
9353
9381
|
}
|
|
9382
|
+
/**
|
|
9383
|
+
* The camera on a bone: through her eyes ("pov", on 頭) or held in her hand
|
|
9384
|
+
* and aimed back at her face ("selfie", on a wrist). See camera-mount.ts.
|
|
9385
|
+
*
|
|
9386
|
+
* Placed every frame after her pose and physics, before the camera is
|
|
9387
|
+
* written, so it never trails her and an export renders what the editor
|
|
9388
|
+
* showed. Outranks the orbit and the follow — which stay as they were
|
|
9389
|
+
* underneath, and come back when the mount goes — but not a camera VMD or
|
|
9390
|
+
* setCameraPose. In POV her head (hair, face, eyes: the materials skinned
|
|
9391
|
+
* mostly to 頭 and below) leaves the camera, and only the camera: her shadow
|
|
9392
|
+
* and her mirror image keep it.
|
|
9393
|
+
*
|
|
9394
|
+
* Null takes the camera off. False when the model is not loaded.
|
|
9395
|
+
*/
|
|
9396
|
+
setCameraMount(model, options) {
|
|
9397
|
+
const prev = this.cameraMount;
|
|
9398
|
+
if (!model || !options) {
|
|
9399
|
+
if (prev)
|
|
9400
|
+
this.dropCameraMount();
|
|
9401
|
+
return true;
|
|
9402
|
+
}
|
|
9403
|
+
let modelName = typeof model === "string" ? model : "";
|
|
9404
|
+
if (typeof model !== "string")
|
|
9405
|
+
for (const i of this.modelInstances.values())
|
|
9406
|
+
if (i.model === model)
|
|
9407
|
+
modelName = i.name;
|
|
9408
|
+
const inst = this.modelInstances.get(modelName);
|
|
9409
|
+
if (!inst)
|
|
9410
|
+
return false;
|
|
9411
|
+
if (prev && prev.name === modelName)
|
|
9412
|
+
prev.mount.setOptions(options);
|
|
9413
|
+
else {
|
|
9414
|
+
if (prev)
|
|
9415
|
+
this.dropCameraMount();
|
|
9416
|
+
this.cameraMount = { name: modelName, mount: new CameraMount(inst.model, options) };
|
|
9417
|
+
}
|
|
9418
|
+
const pov = this.cameraMount.mount.options.mode === "pov";
|
|
9419
|
+
inst.cameraHiddenMaterials = new Set(pov ? headMaterials(inst.model) : []);
|
|
9420
|
+
this.writeCullHidden(true);
|
|
9421
|
+
return true;
|
|
9422
|
+
}
|
|
9423
|
+
getCameraMount() {
|
|
9424
|
+
const m = this.cameraMount;
|
|
9425
|
+
return m ? { ...m.mount.options, model: m.name } : null;
|
|
9426
|
+
}
|
|
9427
|
+
/** The materials a POV mount keeps out of the camera, for a host to show. */
|
|
9428
|
+
getCameraHiddenMaterials(modelName) {
|
|
9429
|
+
return [...(this.modelInstances.get(modelName)?.cameraHiddenMaterials ?? [])];
|
|
9430
|
+
}
|
|
9431
|
+
dropCameraMount() {
|
|
9432
|
+
const prev = this.cameraMount;
|
|
9433
|
+
if (!prev)
|
|
9434
|
+
return;
|
|
9435
|
+
this.cameraMount = null;
|
|
9436
|
+
this.camera.mountPose = null;
|
|
9437
|
+
const inst = this.modelInstances.get(prev.name);
|
|
9438
|
+
if (inst && inst.cameraHiddenMaterials.size > 0) {
|
|
9439
|
+
inst.cameraHiddenMaterials = new Set();
|
|
9440
|
+
this.writeCullHidden(true);
|
|
9441
|
+
}
|
|
9442
|
+
}
|
|
9354
9443
|
/** True while the orbit target is riding a model bone (setCameraFollow). */
|
|
9355
9444
|
isCameraFollowing() {
|
|
9356
9445
|
return this.cameraTargetModel !== null;
|
|
@@ -12674,6 +12763,12 @@ export class Engine {
|
|
|
12674
12763
|
const eye = this.camera.getEyePosition();
|
|
12675
12764
|
const m = inst.model;
|
|
12676
12765
|
_gazeScratch.setXYZ(eye.x - m.position.x, eye.y - m.position.y, eye.z - m.position.z);
|
|
12766
|
+
// Her own first-person camera sits between her eyes: looking AT it
|
|
12767
|
+
// crosses them. She looks where it looks, far ahead along the view.
|
|
12768
|
+
if (this.cameraMount?.name === inst.name && this.cameraMount.mount.options.mode === "pov") {
|
|
12769
|
+
const v = this.camera.getViewMatrix().values;
|
|
12770
|
+
_gazeScratch.setXYZ(_gazeScratch.x + v[2] * 100, _gazeScratch.y + v[6] * 100, _gazeScratch.z + v[10] * 100);
|
|
12771
|
+
}
|
|
12677
12772
|
Quat.rotateVecInvInto(m.rotation, _gazeScratch, _gazeScratch);
|
|
12678
12773
|
const inv = 1 / Math.max(m.scale, 1e-6);
|
|
12679
12774
|
_gazeScratch.setXYZ(_gazeScratch.x * inv, _gazeScratch.y * inv, _gazeScratch.z * inv);
|
|
@@ -12951,9 +13046,11 @@ export class Engine {
|
|
|
12951
13046
|
let changed = force;
|
|
12952
13047
|
for (let i = 0; i < this.cullDraws.length; i++) {
|
|
12953
13048
|
const { inst, draw } = this.cullDraws[i];
|
|
12954
|
-
// bit 0: switched off; bit 1: drawn by its native look, not its graph
|
|
13049
|
+
// bit 0: switched off; bit 1: drawn by its native look, not its graph;
|
|
13050
|
+
// bit 2: out of the camera alone (a POV mount's head)
|
|
12955
13051
|
const v = (inst.hiddenMaterials.has(draw.materialName) || inst.morphHiddenMaterials.has(draw.materialName) ? 1 : 0) |
|
|
12956
|
-
(this.nativeLooks?.dresses(inst.name, draw.materialName) ? 2 : 0)
|
|
13052
|
+
(this.nativeLooks?.dresses(inst.name, draw.materialName) ? 2 : 0) |
|
|
13053
|
+
(inst.cameraHiddenMaterials.has(draw.materialName) ? 4 : 0);
|
|
12957
13054
|
if (out[i] !== v) {
|
|
12958
13055
|
out[i] = v;
|
|
12959
13056
|
changed = true;
|
|
@@ -13999,6 +14096,7 @@ export class Engine {
|
|
|
13999
14096
|
materialIdByName: new Map(),
|
|
14000
14097
|
xrayKey: "",
|
|
14001
14098
|
probeHiddenMaterials: new Set(),
|
|
14099
|
+
cameraHiddenMaterials: new Set(),
|
|
14002
14100
|
materialMorphTargets: null,
|
|
14003
14101
|
materialMorphByIndex: null,
|
|
14004
14102
|
physics,
|
|
@@ -15784,6 +15882,22 @@ export class Engine {
|
|
|
15784
15882
|
}
|
|
15785
15883
|
this.onRaycast(hitModel, hitMaterial, hitBone, screenX, screenY);
|
|
15786
15884
|
}
|
|
15885
|
+
/**
|
|
15886
|
+
* Global playback speed: every clock the frame advances — clips and their
|
|
15887
|
+
* morphs, the camera VMD, physics, tweens, jelly eyes, auto blink, effect
|
|
15888
|
+
* time (rzTime), particles, trails, dissolves, param tracks, scheduled
|
|
15889
|
+
* effects and the camera follow's lag — runs on `delta × scale`, live
|
|
15890
|
+
* (render) and offline (renderFrame) alike. So 0.5 is true slow motion: hair
|
|
15891
|
+
* falls slowly, a sparkle drifts at half pace, and an export stepped at
|
|
15892
|
+
* 1/fps covers half as much of the clip per frame. 0.25–2; frame stats stay
|
|
15893
|
+
* on wall time. The host keeps the music in step (it plays the audio).
|
|
15894
|
+
*/
|
|
15895
|
+
setTimeScale(scale) {
|
|
15896
|
+
this.timeScale = Number.isFinite(scale) ? Math.min(4, Math.max(0.1, scale)) : 1;
|
|
15897
|
+
}
|
|
15898
|
+
getTimeScale() {
|
|
15899
|
+
return this.timeScale;
|
|
15900
|
+
}
|
|
15787
15901
|
render() {
|
|
15788
15902
|
if (!this.multisampleTexture || !this.camera || !this.device)
|
|
15789
15903
|
return;
|
|
@@ -15794,7 +15908,8 @@ export class Engine {
|
|
|
15794
15908
|
}
|
|
15795
15909
|
/**
|
|
15796
15910
|
* Render one frame advancing every clock — animation, physics, tweens, and the
|
|
15797
|
-
* camera VMD — by exactly `deltaSeconds
|
|
15911
|
+
* camera VMD — by exactly `deltaSeconds` (times the time scale, see
|
|
15912
|
+
* setTimeScale), independent of wall time. This is the
|
|
15798
15913
|
* offline-rendering primitive (video export): call it N times with 1/fps and the
|
|
15799
15914
|
* result is deterministic whether the machine renders faster or slower than
|
|
15800
15915
|
* realtime. Also resets the realtime clock so a later render() (returning to the
|
|
@@ -15806,7 +15921,9 @@ export class Engine {
|
|
|
15806
15921
|
this.lastFrameTime = performance.now();
|
|
15807
15922
|
this.renderWithDelta(deltaSeconds);
|
|
15808
15923
|
}
|
|
15809
|
-
renderWithDelta(
|
|
15924
|
+
renderWithDelta(wallDelta) {
|
|
15925
|
+
// Every clock in the frame runs on the scaled delta — see setTimeScale.
|
|
15926
|
+
const deltaTime = wallDelta * this.timeScale;
|
|
15810
15927
|
// The bind groups first, then the textures they used to name. A retired
|
|
15811
15928
|
// texture is freed only once a frame has been rebuilt without it — freeing
|
|
15812
15929
|
// it while a group still points at it is what "destroyed texture used in a
|
|
@@ -15886,6 +16003,16 @@ export class Engine {
|
|
|
15886
16003
|
this.camera.target.y = f.y + this.cameraTargetOffset.y;
|
|
15887
16004
|
this.camera.target.z = f.z + this.cameraTargetOffset.z;
|
|
15888
16005
|
}
|
|
16006
|
+
// The camera on a bone, from this frame's pose (setCameraMount). A rig
|
|
16007
|
+
// that has gone (removed, replaced) takes the mount with it.
|
|
16008
|
+
const cm = this.cameraMount;
|
|
16009
|
+
if (cm) {
|
|
16010
|
+
const inst = this.modelInstances.get(cm.name);
|
|
16011
|
+
if (!inst || inst.model !== cm.mount.model)
|
|
16012
|
+
this.dropCameraMount();
|
|
16013
|
+
else
|
|
16014
|
+
this.camera.mountPose = cm.mount.step(deltaTime);
|
|
16015
|
+
}
|
|
15889
16016
|
}
|
|
15890
16017
|
// Who holds the shot this frame. An external pose is a statement about
|
|
15891
16018
|
// where the camera IS, so it is reapplied rather than sampled — and it
|
|
@@ -15941,7 +16068,9 @@ export class Engine {
|
|
|
15941
16068
|
// The scattering pass is the third reader: it rejects taps across a depth
|
|
15942
16069
|
// step and scales its width by distance, so a scene wearing a subsurface
|
|
15943
16070
|
// look stores depth for as long as it does.
|
|
15944
|
-
|
|
16071
|
+
// Motion blur is a fourth: its velocity pass tests against this depth and
|
|
16072
|
+
// its gather rebuilds the camera's motion from it.
|
|
16073
|
+
const depthRead = dofOn || this.aovCapture || this.effects.some((e) => e.hasForeground) || this.subsurfaceInUse() || this.motionBlur !== null;
|
|
15945
16074
|
this.renderPassDescriptor.depthStencilAttachment.depthStoreOp = depthRead ? "store" : "discard";
|
|
15946
16075
|
if (depthRead)
|
|
15947
16076
|
this.writeDepthOfFieldUniforms();
|
|
@@ -16170,6 +16299,9 @@ export class Engine {
|
|
|
16170
16299
|
// Skin scattering, on the resolved scene and before anything reads it:
|
|
16171
16300
|
// bloom should bleed the scattered skin, not the raw one.
|
|
16172
16301
|
this.renderSubsurface(encoder);
|
|
16302
|
+
// Motion blur, on the finished scene and before bloom, so a streak blooms
|
|
16303
|
+
// as a camera's would.
|
|
16304
|
+
this.renderMotionBlur(encoder, deltaTime);
|
|
16173
16305
|
// The field mounts, likewise: after the scene so foregrounds can read its
|
|
16174
16306
|
// depth, before the composite that samples both layers.
|
|
16175
16307
|
this.renderFieldPass(encoder);
|
|
@@ -16218,9 +16350,10 @@ export class Engine {
|
|
|
16218
16350
|
const dpr = window.devicePixelRatio || 1;
|
|
16219
16351
|
this.resolvePickResult(pick.x / dpr, pick.y / dpr);
|
|
16220
16352
|
}
|
|
16221
|
-
// Feed the true vsync-to-vsync interval (
|
|
16222
|
-
// CPU time spent in render() — that's what actually reflects
|
|
16223
|
-
|
|
16353
|
+
// Feed the true vsync-to-vsync interval (the wall delta, before the time
|
|
16354
|
+
// scale), not the CPU time spent in render() — that's what actually reflects
|
|
16355
|
+
// perceived smoothness.
|
|
16356
|
+
this.updateStats(wallDelta * 1000);
|
|
16224
16357
|
}
|
|
16225
16358
|
drawInstanceShadow(sp, inst, cascade) {
|
|
16226
16359
|
sp.setBindGroup(0, inst.shadowBindGroups[cascade]);
|
|
@@ -16614,6 +16747,259 @@ export class Engine {
|
|
|
16614
16747
|
inst.model.setEyeTracking(options);
|
|
16615
16748
|
return true;
|
|
16616
16749
|
}
|
|
16750
|
+
/**
|
|
16751
|
+
* Auto blink, per model — see Model.setAutoBlink. She blinks on her own
|
|
16752
|
+
* every few seconds, over a morph motion's own blinks. Null hands the morph
|
|
16753
|
+
* back. False for a model that is not loaded or has no closing morph.
|
|
16754
|
+
*/
|
|
16755
|
+
setAutoBlink(modelName, options) {
|
|
16756
|
+
const inst = this.modelInstances.get(modelName);
|
|
16757
|
+
if (!inst)
|
|
16758
|
+
return false;
|
|
16759
|
+
return inst.model.setAutoBlink(options);
|
|
16760
|
+
}
|
|
16761
|
+
getAutoBlink(modelName) {
|
|
16762
|
+
return this.modelInstances.get(modelName)?.model.getAutoBlink() ?? null;
|
|
16763
|
+
}
|
|
16764
|
+
/**
|
|
16765
|
+
* Motion blur on everything that moves: her limbs, hair and cloth from the
|
|
16766
|
+
* pose, everything else from the camera. Per pixel, live and in an export
|
|
16767
|
+
* (the shutter follows the frame's own delta, so a 30 fps export and a
|
|
16768
|
+
* 120 Hz screen streak alike). `shutter` is the fraction of a 1/30 s frame
|
|
16769
|
+
* the shutter is open: 0.5 is film's 180°. Null switches it off, and then it
|
|
16770
|
+
* costs nothing. See shaders/passes/motion-blur.ts.
|
|
16771
|
+
*/
|
|
16772
|
+
setMotionBlur(options) {
|
|
16773
|
+
if (!options) {
|
|
16774
|
+
this.motionBlur = null;
|
|
16775
|
+
this.mbPrevViewProj = null;
|
|
16776
|
+
return;
|
|
16777
|
+
}
|
|
16778
|
+
this.motionBlur = { shutter: Math.min(1, Math.max(0.05, options.shutter ?? 0.5)) };
|
|
16779
|
+
}
|
|
16780
|
+
getMotionBlur() {
|
|
16781
|
+
return this.motionBlur ? { ...this.motionBlur } : null;
|
|
16782
|
+
}
|
|
16783
|
+
mbEnsurePipelines() {
|
|
16784
|
+
if (this.mbVelocityPipeline && this.mbGatherPipeline)
|
|
16785
|
+
return true;
|
|
16786
|
+
if (this.mbVelocityPending)
|
|
16787
|
+
return false;
|
|
16788
|
+
this.mbVelocityPending = true;
|
|
16789
|
+
const device = this.device;
|
|
16790
|
+
this.mbFrameLayout = device.createBindGroupLayout({
|
|
16791
|
+
label: "motion velocity per-frame",
|
|
16792
|
+
entries: [
|
|
16793
|
+
{ binding: 0, visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT, buffer: { type: "uniform" } },
|
|
16794
|
+
{ binding: 1, visibility: GPUShaderStage.VERTEX, buffer: { type: "uniform" } },
|
|
16795
|
+
{ binding: 2, visibility: GPUShaderStage.FRAGMENT, sampler: {} },
|
|
16796
|
+
],
|
|
16797
|
+
});
|
|
16798
|
+
this.mbInstanceLayout = device.createBindGroupLayout({
|
|
16799
|
+
label: "motion velocity per-instance",
|
|
16800
|
+
entries: [
|
|
16801
|
+
{ binding: 0, visibility: GPUShaderStage.VERTEX, buffer: { type: "read-only-storage" } },
|
|
16802
|
+
{ binding: 1, visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT, buffer: { type: "uniform" } },
|
|
16803
|
+
{ binding: 2, visibility: GPUShaderStage.VERTEX, buffer: { type: "read-only-storage" } },
|
|
16804
|
+
],
|
|
16805
|
+
});
|
|
16806
|
+
this.mbPrevCameraBuffer = device.createBuffer({
|
|
16807
|
+
label: "motion blur previous camera",
|
|
16808
|
+
size: 64,
|
|
16809
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
16810
|
+
});
|
|
16811
|
+
this.mbUniformBuffer = device.createBuffer({
|
|
16812
|
+
label: "motion blur uniforms",
|
|
16813
|
+
size: MOTION_BLUR_UNIFORM_FLOATS * 4,
|
|
16814
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
16815
|
+
});
|
|
16816
|
+
this.mbSampler = device.createSampler({ magFilter: "linear", minFilter: "linear", addressModeU: "clamp-to-edge", addressModeV: "clamp-to-edge" });
|
|
16817
|
+
this.mbFrameBindGroup = device.createBindGroup({
|
|
16818
|
+
label: "motion velocity per-frame",
|
|
16819
|
+
layout: this.mbFrameLayout,
|
|
16820
|
+
entries: [
|
|
16821
|
+
{ binding: 0, resource: { buffer: this.cameraUniformBuffer } },
|
|
16822
|
+
{ binding: 1, resource: { buffer: this.mbPrevCameraBuffer } },
|
|
16823
|
+
{ binding: 2, resource: this.materialSampler },
|
|
16824
|
+
],
|
|
16825
|
+
});
|
|
16826
|
+
const velocityModule = device.createShaderModule({ label: "motion velocity", code: motionVelocityWgsl() });
|
|
16827
|
+
const gatherModule = device.createShaderModule({ label: "motion blur gather", code: MOTION_BLUR_WGSL });
|
|
16828
|
+
const velocity = device.createRenderPipelineAsync({
|
|
16829
|
+
label: "motion velocity",
|
|
16830
|
+
layout: device.createPipelineLayout({
|
|
16831
|
+
label: "motion velocity",
|
|
16832
|
+
bindGroupLayouts: [this.mbFrameLayout, this.mbInstanceLayout, this.mainPerMaterialBindGroupLayout],
|
|
16833
|
+
}),
|
|
16834
|
+
vertex: { module: velocityModule, entryPoint: "vs", buffers: this.materialVertexBufferLayouts.slice(0, 3) },
|
|
16835
|
+
fragment: { module: velocityModule, entryPoint: "fs", targets: [{ format: MOTION_VELOCITY_FORMAT }] },
|
|
16836
|
+
primitive: { cullMode: "none" },
|
|
16837
|
+
multisample: { count: Engine.MULTISAMPLE_COUNT },
|
|
16838
|
+
depthStencil: { format: this.depthFormat, depthWriteEnabled: false, depthCompare: this.depthAhead },
|
|
16839
|
+
});
|
|
16840
|
+
const gather = device.createRenderPipelineAsync({
|
|
16841
|
+
label: "motion blur gather",
|
|
16842
|
+
layout: "auto",
|
|
16843
|
+
vertex: { module: gatherModule, entryPoint: "vs" },
|
|
16844
|
+
fragment: { module: gatherModule, entryPoint: "fs", targets: [{ format: this.hdrFormat }] },
|
|
16845
|
+
primitive: { topology: "triangle-list" },
|
|
16846
|
+
});
|
|
16847
|
+
Promise.all([velocity, gather])
|
|
16848
|
+
.then(([v, g]) => {
|
|
16849
|
+
this.mbVelocityPipeline = v;
|
|
16850
|
+
this.mbGatherPipeline = g;
|
|
16851
|
+
})
|
|
16852
|
+
.catch((e) => console.warn("[motion blur] pipelines failed:", e));
|
|
16853
|
+
return false;
|
|
16854
|
+
}
|
|
16855
|
+
/** The motion pass and the gather, on the resolved HDR before bloom. */
|
|
16856
|
+
renderMotionBlur(encoder, deltaTime) {
|
|
16857
|
+
const mb = this.motionBlur;
|
|
16858
|
+
if (!mb || !this.device || !this.hdrResolveTexture || !this.depthReadView)
|
|
16859
|
+
return;
|
|
16860
|
+
const viewProj = this.camera.getProjectionMatrix().multiply(this.camera.getViewMatrix()).values;
|
|
16861
|
+
// The shutter: this frame's motion is deltaTime's worth; the streak is the
|
|
16862
|
+
// shutter's worth of it. No delta (a paused export's first frame, a seek)
|
|
16863
|
+
// or a hitch long enough to be a cut: no blur, and nothing carried over.
|
|
16864
|
+
const scale = deltaTime > 1e-4 && deltaTime < 0.25 ? (mb.shutter / 30) / deltaTime : 0;
|
|
16865
|
+
const prevVP = this.mbPrevViewProj ?? viewProj;
|
|
16866
|
+
if (!this.mbEnsurePipelines() || scale === 0) {
|
|
16867
|
+
this.mbStorePrev(viewProj);
|
|
16868
|
+
return;
|
|
16869
|
+
}
|
|
16870
|
+
const device = this.device;
|
|
16871
|
+
const w = this.hdrResolveTexture.width;
|
|
16872
|
+
const h = this.hdrResolveTexture.height;
|
|
16873
|
+
if (!this.mbVelocity || this.mbVelocity.width !== w || this.mbVelocity.height !== h) {
|
|
16874
|
+
this.mbVelocityMs?.destroy();
|
|
16875
|
+
this.mbVelocity?.destroy();
|
|
16876
|
+
this.mbScratch?.destroy();
|
|
16877
|
+
this.mbVelocityMs = device.createTexture({
|
|
16878
|
+
label: "motion velocity (msaa)",
|
|
16879
|
+
size: [w, h],
|
|
16880
|
+
sampleCount: Engine.MULTISAMPLE_COUNT,
|
|
16881
|
+
format: MOTION_VELOCITY_FORMAT,
|
|
16882
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT,
|
|
16883
|
+
});
|
|
16884
|
+
this.mbVelocity = device.createTexture({
|
|
16885
|
+
label: "motion velocity",
|
|
16886
|
+
size: [w, h],
|
|
16887
|
+
format: MOTION_VELOCITY_FORMAT,
|
|
16888
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
16889
|
+
});
|
|
16890
|
+
this.mbScratch = device.createTexture({
|
|
16891
|
+
label: "motion blur scratch",
|
|
16892
|
+
size: [w, h],
|
|
16893
|
+
format: this.hdrFormat,
|
|
16894
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
|
|
16895
|
+
});
|
|
16896
|
+
this.mbGatherBindGroup = null;
|
|
16897
|
+
}
|
|
16898
|
+
// The HDR resolve and depth are rebuilt on resize; the group follows them.
|
|
16899
|
+
if (!this.mbGatherBindGroup || this.mbGatherDepthView !== this.depthReadView) {
|
|
16900
|
+
this.mbGatherDepthView = this.depthReadView;
|
|
16901
|
+
this.mbGatherBindGroup = device.createBindGroup({
|
|
16902
|
+
label: "motion blur gather",
|
|
16903
|
+
layout: this.mbGatherPipeline.getBindGroupLayout(0),
|
|
16904
|
+
entries: [
|
|
16905
|
+
{ binding: 0, resource: this.hdrResolveTexture.createView() },
|
|
16906
|
+
{ binding: 1, resource: this.mbVelocity.createView() },
|
|
16907
|
+
{ binding: 2, resource: this.depthReadView },
|
|
16908
|
+
{ binding: 3, resource: { buffer: this.mbUniformBuffer } },
|
|
16909
|
+
{ binding: 4, resource: this.mbSampler },
|
|
16910
|
+
],
|
|
16911
|
+
});
|
|
16912
|
+
}
|
|
16913
|
+
// Last frame's camera and poses, then this frame's kept for the next.
|
|
16914
|
+
device.queue.writeBuffer(this.mbPrevCameraBuffer, 0, prevVP);
|
|
16915
|
+
const u = this.mbUniformData;
|
|
16916
|
+
const inv = new Float32Array(16);
|
|
16917
|
+
if (!Mat4.inverseInto(viewProj, inv))
|
|
16918
|
+
inv.set(viewProj);
|
|
16919
|
+
u.set(inv, 0);
|
|
16920
|
+
u.set(prevVP, 16);
|
|
16921
|
+
u[32] = scale;
|
|
16922
|
+
u[33] = Math.max(8, 0.06 * w);
|
|
16923
|
+
u[34] = w;
|
|
16924
|
+
u[35] = h;
|
|
16925
|
+
u[36] = this.depthClear;
|
|
16926
|
+
device.queue.writeBuffer(this.mbUniformBuffer, 0, u);
|
|
16927
|
+
const depthAtt = this.renderPassDescriptor.depthStencilAttachment;
|
|
16928
|
+
const pass = encoder.beginRenderPass({
|
|
16929
|
+
label: "motion velocity",
|
|
16930
|
+
colorAttachments: [
|
|
16931
|
+
{
|
|
16932
|
+
view: this.mbVelocityMs.createView(),
|
|
16933
|
+
resolveTarget: this.mbVelocity.createView(),
|
|
16934
|
+
clearValue: { r: 0, g: 0, b: 0, a: 0 },
|
|
16935
|
+
loadOp: "clear",
|
|
16936
|
+
storeOp: "discard",
|
|
16937
|
+
},
|
|
16938
|
+
],
|
|
16939
|
+
depthStencilAttachment: { view: depthAtt.view, depthReadOnly: true, stencilReadOnly: true },
|
|
16940
|
+
});
|
|
16941
|
+
pass.setPipeline(this.mbVelocityPipeline);
|
|
16942
|
+
pass.setBindGroup(0, this.mbFrameBindGroup);
|
|
16943
|
+
this.forEachInstance((inst) => {
|
|
16944
|
+
if (!inst.model.drawn)
|
|
16945
|
+
return;
|
|
16946
|
+
const s = this.mbInstance(inst);
|
|
16947
|
+
const cur = inst.model.getSkinMatrices();
|
|
16948
|
+
device.queue.writeBuffer(s.prev, 0, (s.last ?? cur));
|
|
16949
|
+
if (!s.last || s.last.length !== cur.length)
|
|
16950
|
+
s.last = new Float32Array(cur.length);
|
|
16951
|
+
s.last.set(cur);
|
|
16952
|
+
this.setModelDrawState(pass, inst);
|
|
16953
|
+
pass.setBindGroup(1, s.bindGroup);
|
|
16954
|
+
for (const draw of inst.drawCalls) {
|
|
16955
|
+
if (draw.type !== "opaque" && draw.type !== "transparent")
|
|
16956
|
+
continue;
|
|
16957
|
+
pass.setBindGroup(2, draw.bindGroup);
|
|
16958
|
+
this.issueDraw(pass, draw, "camera");
|
|
16959
|
+
}
|
|
16960
|
+
});
|
|
16961
|
+
pass.end();
|
|
16962
|
+
const gather = encoder.beginRenderPass({
|
|
16963
|
+
label: "motion blur gather",
|
|
16964
|
+
colorAttachments: [{ view: this.mbScratch.createView(), loadOp: "clear", clearValue: [0, 0, 0, 0], storeOp: "store" }],
|
|
16965
|
+
});
|
|
16966
|
+
gather.setPipeline(this.mbGatherPipeline);
|
|
16967
|
+
gather.setBindGroup(0, this.mbGatherBindGroup);
|
|
16968
|
+
gather.draw(3);
|
|
16969
|
+
gather.end();
|
|
16970
|
+
encoder.copyTextureToTexture({ texture: this.mbScratch }, { texture: this.hdrResolveTexture }, [w, h]);
|
|
16971
|
+
this.mbStorePrev(viewProj);
|
|
16972
|
+
}
|
|
16973
|
+
mbStorePrev(viewProj) {
|
|
16974
|
+
if (!this.mbPrevViewProj)
|
|
16975
|
+
this.mbPrevViewProj = new Float32Array(16);
|
|
16976
|
+
this.mbPrevViewProj.set(viewProj);
|
|
16977
|
+
}
|
|
16978
|
+
/** A model's last-frame skin buffer and its velocity bind group, rebuilt if
|
|
16979
|
+
* the model's own buffers were replaced. */
|
|
16980
|
+
mbInstance(inst) {
|
|
16981
|
+
let s = this.mbInstances.get(inst);
|
|
16982
|
+
if (s && s.skin === inst.skinMatrixBuffer && s.light === inst.lightBuffer)
|
|
16983
|
+
return s;
|
|
16984
|
+
s?.prev.destroy();
|
|
16985
|
+
const prev = this.device.createBuffer({
|
|
16986
|
+
label: `${inst.name}: previous skin`,
|
|
16987
|
+
size: inst.skinMatrixBuffer.size,
|
|
16988
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
16989
|
+
});
|
|
16990
|
+
const bindGroup = this.device.createBindGroup({
|
|
16991
|
+
label: `${inst.name}: motion velocity`,
|
|
16992
|
+
layout: this.mbInstanceLayout,
|
|
16993
|
+
entries: [
|
|
16994
|
+
{ binding: 0, resource: { buffer: inst.skinMatrixBuffer } },
|
|
16995
|
+
{ binding: 1, resource: { buffer: inst.lightBuffer } },
|
|
16996
|
+
{ binding: 2, resource: { buffer: prev } },
|
|
16997
|
+
],
|
|
16998
|
+
});
|
|
16999
|
+
s = { prev, bindGroup, last: null, skin: inst.skinMatrixBuffer, light: inst.lightBuffer };
|
|
17000
|
+
this.mbInstances.set(inst, s);
|
|
17001
|
+
return s;
|
|
17002
|
+
}
|
|
16617
17003
|
/**
|
|
16618
17004
|
* A repeating dissolve on one model, on the scene clock.
|
|
16619
17005
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Engine, DEFAULT_BLOOM_OPTIONS, DEFAULT_DEPTH_OF_FIELD_OPTIONS, DEFAULT_VIEW_TRANSFORM, DEFAULT_COLOR_GRADING, type ColorGradingOptions, type StageGradeLut, type SceneFog, type StageCastShadow, type SceneFogLayer, type EngineStats, type EngineOptions, type BloomOptions, type DepthOfFieldOptions, type ViewTransformOptions, type ViewTransformName, type LoadModelFromFilesOptions, type MaterialPreset, type MaterialPresetMap, type ModelTransform, type SceneLight, type CastKey, RENDERING_LAYER_DEFAULT, RENDERING_LAYER_CHARACTER, type ModelAttachment, type SceneAovs, type LightProbe, type ReflectionProbeRegion, type PixelFilterType, type GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, type EffectPointValue, type EffectBoneValue, type EffectParamKey, type EffectResult, type ViewLut, type CullDiagnostics, type MidiNote, } from "./engine";
|
|
1
|
+
export { Engine, DEFAULT_BLOOM_OPTIONS, DEFAULT_DEPTH_OF_FIELD_OPTIONS, DEFAULT_VIEW_TRANSFORM, DEFAULT_COLOR_GRADING, type ColorGradingOptions, type StageGradeLut, type SceneFog, type StageCastShadow, type SceneFogLayer, type EngineStats, type EngineOptions, type BloomOptions, type DepthOfFieldOptions, type ViewTransformOptions, type ViewTransformName, type LoadModelFromFilesOptions, type MaterialPreset, type MaterialPresetMap, type ModelTransform, type SceneLight, type CastKey, RENDERING_LAYER_DEFAULT, RENDERING_LAYER_CHARACTER, type ModelAttachment, type SceneAovs, type LightProbe, type ReflectionProbeRegion, type PixelFilterType, type GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, type EffectPointValue, type EffectBoneValue, type EffectParamKey, type EffectResult, type ViewLut, type CullDiagnostics, type MidiNote, type MotionBlurOptions, } from "./engine";
|
|
2
2
|
export { parsePmxFolderInput, pmxFileAtRelativePath, type PmxFolderInputResult } from "./folder-upload";
|
|
3
3
|
export { parseMidi } from "./midi-loader";
|
|
4
4
|
export { parseHDR, type HdrImage } from "./hdr";
|
|
@@ -50,7 +50,8 @@ export { boneOverlay, boneMarkerPositions, rigidbodyOverlay, jointOverlay, build
|
|
|
50
50
|
* Pure strings, no GPU: importing them costs a host nothing.
|
|
51
51
|
*/
|
|
52
52
|
export { EFFECT_MATH_API, PARTICLE_STRUCT_WGSL } from "./shaders/passes/hosted-api";
|
|
53
|
-
export type { EyeTrackingOptions } from "./model";
|
|
53
|
+
export type { EyeTrackingOptions, AutoBlinkOptions } from "./model";
|
|
54
|
+
export type { CameraMountOptions, CameraMountMode } from "./camera-mount";
|
|
54
55
|
export type { JellyEyeOptions } from "./jelly-eyes";
|
|
55
56
|
/**
|
|
56
57
|
* The game's own materials (src/unity): a stage package drawn by its translated
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,qBAAqB,EACrB,8BAA8B,EAC9B,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,qBAAqB,EACrB,8BAA8B,EAC9B,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KA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gB,EAAE,MAAM,cAAc,CAAA;AAClE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/model.d.ts
CHANGED
|
@@ -3,6 +3,16 @@ import { type AssetReader } from "./asset-reader";
|
|
|
3
3
|
import { Rigidbody, Joint } from "./physics";
|
|
4
4
|
import { type VmdTrackSelection } from "./vmd-writer";
|
|
5
5
|
import { AnimationClip, AnimationPlayOptions, AnimationProgress, BlendEntry } from "./animation";
|
|
6
|
+
/** What setAutoBlink asks for. */
|
|
7
|
+
export interface AutoBlinkOptions {
|
|
8
|
+
/** The average gap between blinks, seconds; each gap is drawn from half to
|
|
9
|
+
* one and a half times it. 1–10, default 4. */
|
|
10
|
+
interval?: number;
|
|
11
|
+
/** How fast one blink is: 2 takes half as long. 0.5–2, default 1. */
|
|
12
|
+
speed?: number;
|
|
13
|
+
/** Whether a blink is now and then followed straight by a second. Default true. */
|
|
14
|
+
double?: boolean;
|
|
15
|
+
}
|
|
6
16
|
/** What setEyeTracking asks for. */
|
|
7
17
|
export interface EyeTrackingOptions {
|
|
8
18
|
/** 0..1 — how much of the solved gaze replaces the motion's own. Default 1. */
|
|
@@ -469,6 +479,31 @@ export declare class Model {
|
|
|
469
479
|
*/
|
|
470
480
|
setEyeTracking(options: EyeTrackingOptions | null): void;
|
|
471
481
|
hasEyeTracking(): boolean;
|
|
482
|
+
/** The closing morphs auto blink drives (one for both eyes, or a left and
|
|
483
|
+
* right pair), or null while it is off. */
|
|
484
|
+
private autoBlink;
|
|
485
|
+
/**
|
|
486
|
+
* Auto blink: she blinks every few seconds on her own, as eyes do — a
|
|
487
|
+
* natural irregular gap around `interval`, now and then a double blink.
|
|
488
|
+
*
|
|
489
|
+
* A MORPH, on the model's own closing morph (まばたき, or a left and right
|
|
490
|
+
* wink pair when there is none). It OWNS that morph while on, as eye
|
|
491
|
+
* tracking owns the eye bones: a morph motion's own まばたき keys are
|
|
492
|
+
* replaced, and handed back when it goes off. Its other expressions (a
|
|
493
|
+
* smile, a wince) play as keyed. Steps on the scene clock (the delta
|
|
494
|
+
* update() is handed, every frame, playing or paused) through a fixed
|
|
495
|
+
* sequence of gaps.
|
|
496
|
+
*
|
|
497
|
+
* Null hands the morph back. Returns false for a model with no closing morph.
|
|
498
|
+
*/
|
|
499
|
+
setAutoBlink(options: AutoBlinkOptions | null): boolean;
|
|
500
|
+
getAutoBlink(): Required<AutoBlinkOptions> | null;
|
|
501
|
+
/** The morphs that close both eyes, by the names MMD, VRoid and the usual
|
|
502
|
+
* converters give them. A smile or a wince closes them too and is no blink. */
|
|
503
|
+
private blinkMorphs;
|
|
504
|
+
/** One frame of auto blink, after the pose sources set the morphs and before
|
|
505
|
+
* they are applied. True when it moved a weight. */
|
|
506
|
+
private stepAutoBlink;
|
|
472
507
|
/**
|
|
473
508
|
* Where she looks: a unit direction in model space, or null for a model
|
|
474
509
|
* without eye bones. See RzSubject.gaze.
|