reze-engine 0.68.15 → 0.68.17

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.
Files changed (62) hide show
  1. package/dist/engine.d.ts +77 -6
  2. package/dist/engine.d.ts.map +1 -1
  3. package/dist/engine.js +129 -31
  4. package/dist/graph/presets/pool_floor.d.ts +3 -0
  5. package/dist/graph/presets/pool_floor.d.ts.map +1 -0
  6. package/dist/graph/presets/pool_floor.js +42 -0
  7. package/dist/graph/presets/water.d.ts +3 -0
  8. package/dist/graph/presets/water.d.ts.map +1 -0
  9. package/dist/graph/presets/water.js +31 -0
  10. package/dist/graph/registry.d.ts.map +1 -1
  11. package/dist/graph/registry.js +4 -1
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/physics/autofit.d.ts +147 -0
  15. package/dist/physics/autofit.d.ts.map +1 -0
  16. package/dist/physics/autofit.js +501 -0
  17. package/dist/shaders/agx-lut.d.ts +11 -0
  18. package/dist/shaders/agx-lut.d.ts.map +1 -0
  19. package/dist/shaders/agx-lut.js +29 -0
  20. package/dist/shaders/dfg_lut.d.ts +3 -0
  21. package/dist/shaders/dfg_lut.d.ts.map +1 -0
  22. package/dist/shaders/dfg_lut.js +129 -0
  23. package/dist/shaders/lights.d.ts +1 -1
  24. package/dist/shaders/lights.d.ts.map +1 -1
  25. package/dist/shaders/lights.js +89 -6
  26. package/dist/shaders/ltc_mag_lut.d.ts +3 -0
  27. package/dist/shaders/ltc_mag_lut.d.ts.map +1 -0
  28. package/dist/shaders/ltc_mag_lut.js +1033 -0
  29. package/dist/shaders/materials/common.d.ts.map +1 -1
  30. package/dist/shaders/materials/common.js +2 -1
  31. package/dist/shaders/materials/nodes.d.ts +1 -1
  32. package/dist/shaders/materials/nodes.d.ts.map +1 -1
  33. package/dist/shaders/materials/nodes.js +182 -13
  34. package/dist/shaders/passes/composite.d.ts.map +1 -1
  35. package/dist/shaders/passes/composite.js +59 -4
  36. package/dist/shaders/passes/field-blit.d.ts +26 -0
  37. package/dist/shaders/passes/field-blit.d.ts.map +1 -0
  38. package/dist/shaders/passes/field-blit.js +65 -0
  39. package/dist/shaders/passes/ghosts.d.ts +22 -0
  40. package/dist/shaders/passes/ghosts.d.ts.map +1 -0
  41. package/dist/shaders/passes/ghosts.js +75 -0
  42. package/dist/shaders/passes/ground-noise.d.ts +7 -0
  43. package/dist/shaders/passes/ground-noise.d.ts.map +1 -0
  44. package/dist/shaders/passes/ground-noise.js +88 -0
  45. package/dist/shaders/passes/sim.d.ts +34 -0
  46. package/dist/shaders/passes/sim.d.ts.map +1 -0
  47. package/dist/shaders/passes/sim.js +169 -0
  48. package/dist/shaders/score-api.d.ts +10 -0
  49. package/dist/shaders/score-api.d.ts.map +1 -0
  50. package/dist/shaders/score-api.js +114 -0
  51. package/dist/shaders/shadow-api.d.ts +29 -0
  52. package/dist/shaders/shadow-api.d.ts.map +1 -0
  53. package/dist/shaders/shadow-api.js +112 -0
  54. package/package.json +1 -1
  55. package/src/engine.ts +154 -31
  56. package/src/graph/registry.ts +4 -1
  57. package/src/index.ts +2 -0
  58. package/src/shaders/lights.ts +89 -6
  59. package/src/shaders/materials/common.ts +2 -1
  60. package/src/shaders/materials/nodes.ts +182 -13
  61. package/src/shaders/passes/composite.ts +59 -4
  62. package/dist/_dbg-loader.mjs +0 -1100
package/dist/engine.js CHANGED
@@ -1151,6 +1151,9 @@ export class Engine {
1151
1151
  /** Off: no capture, and every reader falls back to the sky — see
1152
1152
  * setReflectionProbe. */
1153
1153
  this.probeEnabled = true;
1154
+ /** A local probe's capture point and box, world space — see
1155
+ * setReflectionProbe. Null: the stage's middle and bounds. */
1156
+ this.probeRegion = null;
1154
1157
  this.probeCapture = null;
1155
1158
  this.skyPrefilterPipeline = null;
1156
1159
  // The scene's user WGSL effect (setEffect). ONE per scene, mounted under the
@@ -1376,6 +1379,9 @@ export class Engine {
1376
1379
  };
1377
1380
  /** Sensor grain: how much. */
1378
1381
  this.grain = { amount: 0 };
1382
+ /** The pixel filter: its width in pixels (0 off) and the 1D weights of
1383
+ * offsets 0, ±1, ±2 it comes to — see setPixelFilter. */
1384
+ this.pixelFilter = { width: 0, type: "blackman-harris", weights: [1, 0, 0] };
1379
1385
  /** Debug/diagnostic: skip every inverted-hull outline draw. */
1380
1386
  // OFF by default — the product aesthetic. Modern high-detail models read
1381
1387
  // better without hulls (babylon-mmd's own demos disable its outline renderer
@@ -1974,6 +1980,55 @@ export class Engine {
1974
1980
  getFilmGrain() {
1975
1981
  return this.grain;
1976
1982
  }
1983
+ /**
1984
+ * A renderer's pixel filter, over the rendered scene: how Cycles builds a
1985
+ * pixel from the light around it rather than from its own square alone.
1986
+ * Off (width 0) the engine's pixels are their own box, which is what it has
1987
+ * always drawn.
1988
+ *
1989
+ * Cycles samples each pixel through a Blackman-Harris window twice the
1990
+ * filter width across (1.5 px by default, so 3 px), or a box that width
1991
+ * across. It is invisible on ordinary surfaces and decides what a thing
1992
+ * smaller than a pixel and far brighter than white looks like: a 3 cm ember
1993
+ * glowing at twenty times white spreads into the pixels around it and reads
1994
+ * as a coloured square, and a neon edge gets its coloured fringe. The engine
1995
+ * resolves its samples to a box first, so the filter here is that window
1996
+ * integrated over each neighbour's square — the nearest staircase to it —
1997
+ * applied to the scene's HDR light before the view transform, coverage
1998
+ * alongside, so the sky behind it composites as before. Up to 2.5 px wide
1999
+ * (5×5 taps), one more pass of reads in the composite, none when off.
2000
+ */
2001
+ setPixelFilter(width, type = "blackman-harris") {
2002
+ const w = Number.isFinite(width) ? Math.min(Math.max(width, 0), 2.5) : 0;
2003
+ // The window's full span in pixels and its shape over u in 0..1.
2004
+ const span = type === "box" ? w : w * 2;
2005
+ const shape = (u) => type === "box"
2006
+ ? 1
2007
+ : 0.35875 - 0.48829 * Math.cos(2 * Math.PI * u) + 0.14128 * Math.cos(4 * Math.PI * u) - 0.01168 * Math.cos(6 * Math.PI * u);
2008
+ const weights = [1, 0, 0];
2009
+ if (span > 1e-3) {
2010
+ // Each offset's square, [d − ½, d + ½], integrated over the window.
2011
+ const n = 64;
2012
+ for (let d = 0; d < 3; d++) {
2013
+ let sum = 0;
2014
+ for (let i = 0; i < n; i++) {
2015
+ const x = d - 0.5 + (i + 0.5) / n;
2016
+ if (Math.abs(x) < span / 2)
2017
+ sum += shape(x / span + 0.5) / n;
2018
+ }
2019
+ weights[d] = sum;
2020
+ }
2021
+ const total = weights[0] + 2 * weights[1] + 2 * weights[2];
2022
+ for (let d = 0; d < 3; d++)
2023
+ weights[d] /= total;
2024
+ }
2025
+ this.pixelFilter = { width: w, type, weights };
2026
+ if (this.device && this.compositeUniformBuffer)
2027
+ this.writeCompositeViewUniforms();
2028
+ }
2029
+ getPixelFilter() {
2030
+ return { width: this.pixelFilter.width, type: this.pixelFilter.type };
2031
+ }
1977
2032
  setViewTransformOptions(patch) {
1978
2033
  const v = this.viewTransform;
1979
2034
  if (patch.exposure !== undefined)
@@ -2055,6 +2110,11 @@ export class Engine {
2055
2110
  // The soft curve's power (viewU[15].x), the scene's own (SceneSetting._contrast).
2056
2111
  // Its own vec4: viewU[11..14] are the cast's positions whenever an effect runs.
2057
2112
  u[60] = v.contrast;
2113
+ // The pixel filter's 1D weights for offsets 0, ±1, ±2 (viewU[15].yzw);
2114
+ // 1, 0, 0 is off — see setPixelFilter.
2115
+ u[61] = this.pixelFilter.weights[0];
2116
+ u[62] = this.pixelFilter.weights[1];
2117
+ u[63] = this.pixelFilter.weights[2];
2058
2118
  // ── Grade (viewU[7..9]) ── The UI's three tonal COLORS map to ASC CDL here,
2059
2119
  // on the CPU, so the shader only ever sees slope/offset/power. Mid-gray is
2060
2120
  // neutral in all three; the signed distance from it is the amount.
@@ -9117,11 +9177,19 @@ export class Engine {
9117
9177
  /** Whether the stage reflects its own capture (the default) or the sky. Off
9118
9178
  * is for a stage whose sky was measured from inside it — a Blender export's
9119
9179
  * world — where a capture lit without the lamps' shadows comes out too
9120
- * bright on a shiny floor. */
9121
- setReflectionProbe(enabled) {
9122
- if (this.probeEnabled === enabled)
9180
+ * bright on a shiny floor.
9181
+ *
9182
+ * With a region the probe is LOCAL, as a room's box probe is in Unity:
9183
+ * captured from region.center, box-projected onto region.min..max, and a
9184
+ * surface outside that box reflects the sky — a tunnel's glossy walls
9185
+ * mirror its neon while the floor around it keeps the world. Null: the
9186
+ * stage's middle and bounds, every surface. */
9187
+ setReflectionProbe(enabled, region = null) {
9188
+ const same = (a, b) => a === b || (!!a && !!b && [0, 1, 2].every((k) => a.center[k] === b.center[k] && a.min[k] === b.min[k] && a.max[k] === b.max[k]));
9189
+ if (this.probeEnabled === enabled && same(this.probeRegion, region))
9123
9190
  return;
9124
9191
  this.probeEnabled = enabled;
9192
+ this.probeRegion = region && [region.center, region.min, region.max].every((v) => v.length >= 3 && v.every(Number.isFinite)) ? region : null;
9125
9193
  this.captureReflectionProbe();
9126
9194
  }
9127
9195
  /** The stage's world-space bounds: every stage model's material boxes
@@ -9165,7 +9233,8 @@ export class Engine {
9165
9233
  if (!settled && this.probeFrame - this.probeAskedFrame < Engine.PROBE_MAX_WAIT_FRAMES)
9166
9234
  return;
9167
9235
  this.probeDirty = false;
9168
- const bounds = this.probeEnabled ? this.stageBounds() : null;
9236
+ const region = this.probeRegion;
9237
+ const bounds = !this.probeEnabled ? null : region ? { min: region.min, max: region.max } : this.stageBounds();
9169
9238
  if (!bounds) {
9170
9239
  // No stage, or the probe is off: it goes dark and every reader falls
9171
9240
  // back to the sky.
@@ -9174,7 +9243,7 @@ export class Engine {
9174
9243
  return;
9175
9244
  }
9176
9245
  try {
9177
- this.renderProbe(bounds);
9246
+ this.renderProbe(bounds, region?.center ?? null);
9178
9247
  }
9179
9248
  catch (e) {
9180
9249
  console.warn("[reze-engine] reflection probe capture failed:", e);
@@ -9295,19 +9364,22 @@ export class Engine {
9295
9364
  * the MMD convention, else their bottom) — where a game puts the probe of a
9296
9365
  * room the player stands in. The box it projects onto is the bounds.
9297
9366
  *
9367
+ * A LOCAL probe (setReflectionProbe's region) is captured from the point
9368
+ * it names and projects onto its own box; a surface outside that box
9369
+ * reflects the sky, as Unity's box probes fall back to the skybox past
9370
+ * their bounds.
9371
+ *
9298
9372
  * WHAT: the stage alone, in its own looks, lit by the scene's sun, lamps
9299
9373
  * and sky as they stand. The cast is not in it (a baked probe never holds
9300
9374
  * the characters), nor are effects.
9301
9375
  */
9302
- renderProbe(bounds) {
9376
+ renderProbe(bounds, at) {
9303
9377
  const cap = this.ensureProbeCapture();
9304
9378
  const { min, max } = bounds;
9305
9379
  const floor = min[1] <= 0 && max[1] >= 0 ? 0 : min[1];
9306
- const eye = [
9307
- (min[0] + max[0]) * 0.5,
9308
- Math.min(floor + 12, (min[1] + max[1]) * 0.5),
9309
- (min[2] + max[2]) * 0.5,
9310
- ];
9380
+ const eye = at
9381
+ ? [at[0], at[1], at[2]]
9382
+ : [(min[0] + max[0]) * 0.5, Math.min(floor + 12, (min[1] + max[1]) * 0.5), (min[2] + max[2]) * 0.5];
9311
9383
  const span = Math.hypot(max[0] - min[0], max[1] - min[1], max[2] - min[2]);
9312
9384
  const near = 0.25;
9313
9385
  const far = Math.max(span * 2, 100);
@@ -9433,7 +9505,8 @@ export class Engine {
9433
9505
  for (let f = 0; f < 6; f++)
9434
9506
  run(face(this.probeTexture, m, f), cap.filterPipeline, cap.filterGroups[m * 6 + f]);
9435
9507
  this.device.queue.submit([encoder.finish()]);
9436
- this.probeData.set([eye[0], eye[1], eye[2], 1, min[0], min[1], min[2], 1, max[0], max[1], max[2], 0]);
9508
+ // boxMax.w: 1 for a local probe, whose outside reflects the sky.
9509
+ this.probeData.set([eye[0], eye[1], eye[2], 1, min[0], min[1], min[2], 1, max[0], max[1], max[2], at ? 1 : 0]);
9437
9510
  this.device.queue.writeBuffer(this.probeUniformBuffer, 0, this.probeData);
9438
9511
  }
9439
9512
  /**
@@ -9955,13 +10028,22 @@ export class Engine {
9955
10028
  // rewrites the lamps when it lands).
9956
10029
  const cookie = l.cookie !== undefined ? this.cookieLayers.get(l.cookie) : undefined;
9957
10030
  this.lightsData[b + 15] = cookie !== undefined ? cookie + 1 : 0;
10031
+ // A tube's half-axis; zero for a point (a non-finite one is a point too)
10032
+ const tube = l.tube && [l.tube.x, l.tube.y, l.tube.z].every(Number.isFinite) && l.kind !== "directional" ? l.tube : null;
10033
+ this.lightsData[b + 16] = tube ? tube.x : 0;
10034
+ this.lightsData[b + 17] = tube ? tube.y : 0;
10035
+ this.lightsData[b + 18] = tube ? tube.z : 0;
10036
+ this.lightsData[b + 19] = 0;
9958
10037
  }
9959
10038
  // The grid, from the records as STORED — normalised aim, clamped reach, the
9960
10039
  // cosines in f32 — so it indexes exactly what the shader will evaluate.
9961
10040
  const grid = buildLightGrid(list.map((_, i) => {
9962
10041
  const b = LIGHT_HEADER + i * LIGHT_STRIDE;
9963
10042
  const d = this.lightsData;
9964
- return { x: d[b], y: d[b + 1], z: d[b + 2], radius: d[b + 3], ax: d[b + 8], ay: d[b + 9], az: d[b + 10], cosOuter: d[b + 11] };
10043
+ // a tube reaches its radius from any point of its segment: past the
10044
+ // middle by its half-length, and a cone is no bound along it
10045
+ const half = Math.hypot(d[b + 16], d[b + 17], d[b + 18]);
10046
+ return { x: d[b], y: d[b + 1], z: d[b + 2], radius: d[b + 3] + half, ax: d[b + 8], ay: d[b + 9], az: d[b + 10], cosOuter: half > 0 ? -1 : d[b + 11] };
9965
10047
  }));
9966
10048
  this.lightHeader.set(grid.origin, 4);
9967
10049
  this.lightHeader[7] = 1 / grid.cell;
@@ -11615,6 +11697,22 @@ export class Engine {
11615
11697
  else
11616
11698
  inst.hiddenMaterials.add(materialName);
11617
11699
  }
11700
+ /**
11701
+ * Whether the reflection probe captures a material. Off for a glowing strip
11702
+ * whose light a TUBE LAMP already carries (SceneLight.tube): the lamp draws
11703
+ * its reflection in every glossy surface, exactly, and the probe's picture
11704
+ * of the same strip would put it there a second time. Re-captures the probe.
11705
+ */
11706
+ setMaterialInProbe(modelName, materialName, inProbe) {
11707
+ const inst = this.modelInstances.get(modelName);
11708
+ if (!inst || inst.probeHiddenMaterials.has(materialName) === !inProbe)
11709
+ return;
11710
+ if (inProbe)
11711
+ inst.probeHiddenMaterials.delete(materialName);
11712
+ else
11713
+ inst.probeHiddenMaterials.add(materialName);
11714
+ this.captureReflectionProbe();
11715
+ }
11618
11716
  toggleMaterialVisible(modelName, materialName) {
11619
11717
  const inst = this.modelInstances.get(modelName);
11620
11718
  if (!inst)
@@ -13194,6 +13292,7 @@ export class Engine {
13194
13292
  skinMatricesDirty: true,
13195
13293
  hiddenMaterials: new Set(),
13196
13294
  morphHiddenMaterials: new Set(),
13295
+ probeHiddenMaterials: new Set(),
13197
13296
  materialMorphTargets: null,
13198
13297
  materialMorphByIndex: null,
13199
13298
  physics,
@@ -15763,25 +15862,20 @@ export class Engine {
15763
15862
  this.dissolveCycles.set(modelName, cycle);
15764
15863
  return true;
15765
15864
  }
15766
- /** The model at one cast slot — the subject rzSubject(index) reads. */
15767
- castSubjectName(index, subjects = null) {
15865
+ /** The models an effect's rzSubject(i) reads, in its own index order: the
15866
+ * ones it is aimed at, or the whole cast when it is aimed at nobody. */
15867
+ castSubjectNames(subjects = null) {
15868
+ const names = [];
15768
15869
  let n = 0;
15769
- let local = 0;
15770
- let found = null;
15771
15870
  this.forEachInstance((inst) => {
15772
- if (found !== null || n >= MAX_EFFECT_SUBJECTS || inst.isStage || inst.isPlane || inst.isProp || !inst.model.visible)
15871
+ if (n >= MAX_EFFECT_SUBJECTS || inst.isStage || inst.isPlane || inst.isProp || !inst.model.visible)
15773
15872
  return;
15774
15873
  n++;
15775
- // The effect's OWN index, which is what its shaders count in: an effect
15776
- // aimed at the third dancer finds her at 0, so a #dissolve on it takes HER
15777
- // apart rather than whoever stands at the head of the cast.
15778
15874
  if (subjects && !subjects.includes(inst.name))
15779
15875
  return;
15780
- if (local === index)
15781
- found = inst.name;
15782
- local++;
15876
+ names.push(inst.name);
15783
15877
  });
15784
- return found;
15878
+ return names;
15785
15879
  }
15786
15880
  /** One effect's four durations: its dials where it declares them, the
15787
15881
  * constants it wrote where it does not. */
@@ -15801,8 +15895,8 @@ export class Engine {
15801
15895
  *
15802
15896
  * Two things ask for one. A cycle set on a model (setModelDissolveCycle) runs
15803
15897
  * on the scene clock and repeats, as it always has. An effect declaring
15804
- * `#dissolve` takes ITS OWN subject 0 apart on its own terms — the first model
15805
- * it is aimed at, the head of the cast when it is aimed at nobody in
15898
+ * `#dissolve` takes every one of ITS subjects apart on its own terms — the
15899
+ * models it is aimed at, the whole cast when it is aimed at nobody in
15806
15900
  * particular: scheduled, the cycle on each clip's clock with her whole between
15807
15901
  * clips; unscheduled, the same repeating cycle as before. Where both ask, the more dissolved wins — two
15808
15902
  * answers about one body, and half a body is not one of them.
@@ -15817,16 +15911,18 @@ export class Engine {
15817
15911
  if (!fx.dissolve)
15818
15912
  continue;
15819
15913
  const cycle = dissolveCycleOf(this.dissolveTimingsOf(fx, fx.dissolve));
15820
- const subject = this.castSubjectName(0, fx.subjects);
15821
- if (!cycle || !subject)
15914
+ if (!cycle)
15822
15915
  continue;
15916
+ let v;
15823
15917
  if (fx.window && fx.window.length > 0) {
15824
15918
  transport ?? (transport = this.transportTime());
15825
- put(subject, scheduledDissolve(fx.window, cycle, transport));
15919
+ v = scheduledDissolve(fx.window, cycle, transport);
15826
15920
  }
15827
15921
  else {
15828
- put(subject, sampleDissolveCycle(cycle, this.sceneClock));
15922
+ v = sampleDissolveCycle(cycle, this.sceneClock);
15829
15923
  }
15924
+ for (const subject of this.castSubjectNames(fx.subjects))
15925
+ put(subject, v);
15830
15926
  }
15831
15927
  for (const name of this.dissolveTouched)
15832
15928
  if (!want.has(name))
@@ -16494,6 +16590,8 @@ export class Engine {
16494
16590
  // The probe draws directly, past the cull: honour the switches it holds.
16495
16591
  if (view.args === "probe" && !this.shouldRenderDrawCall(inst, draw))
16496
16592
  continue;
16593
+ if (view.args === "probe" && inst.probeHiddenMaterials.has(draw.materialName))
16594
+ continue;
16497
16595
  if (!bound) {
16498
16596
  pass.setBindGroup(0, view.perFrame);
16499
16597
  pass.setBindGroup(1, inst.mainPerInstanceBindGroup);
@@ -0,0 +1,3 @@
1
+ import type { ShaderGraph } from "../schema";
2
+ export declare const POOL_FLOOR_GRAPH: ShaderGraph;
3
+ //# sourceMappingURL=pool_floor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool_floor.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/pool_floor.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,eAAO,MAAM,gBAAgB,EAAE,WA6B9B,CAAA"}
@@ -0,0 +1,42 @@
1
+ // Pool floor — the tiled bottom seen through water, with caustics on it.
2
+ //
3
+ // The other half of a pool, and the half that does most of the work. A water
4
+ // surface can be tuned for a long time without the shot reading as a pool;
5
+ // putting the focused-light web on the FLOOR is what settles it, because that
6
+ // is the cue a photograph actually carries. It is a floor material, so it is
7
+ // applied to the tile under the water rather than to the water itself.
8
+ //
9
+ // Caustics land between the albedo and the shading deliberately: they are
10
+ // light, so they should still be dimmed by the floor's own shadow rather than
11
+ // glowing through it. That is the difference between water-focused sun and a
12
+ // decal.
13
+ export const POOL_FLOOR_GRAPH = {
14
+ version: 1,
15
+ name: "Pool floor",
16
+ tags: ["stage", "water", "pool"],
17
+ nodes: [
18
+ { id: "tex", type: "texture" },
19
+ { id: "mat", type: "material_diffuse" },
20
+ { id: "base", type: "mix/multiply", inputs: { fac: 1.0 } },
21
+ { id: "caust", type: "caustics" },
22
+ {
23
+ id: "principled",
24
+ type: "principled",
25
+ inputs: { metallic: 0.0, specular_ior_level: 0.4, roughness: 0.45, spec_clamp: 10.0, sheen_weight: 0.0, sheen_tint: 0.0 },
26
+ },
27
+ ],
28
+ links: [
29
+ { from: { node: "tex", socket: "color" }, to: { node: "base", socket: "a" } },
30
+ { from: { node: "mat", socket: "color" }, to: { node: "base", socket: "b" } },
31
+ { from: { node: "base", socket: "color" }, to: { node: "caust", socket: "color" } },
32
+ { from: { node: "caust", socket: "color" }, to: { node: "principled", socket: "base_color" } },
33
+ ],
34
+ output: { node: "principled", socket: "color" },
35
+ params: [
36
+ { id: "tint", label: "Light tint", target: { node: "caust", socket: "tint" }, kind: "color", default: [1.0, 1.0, 1.0] },
37
+ { id: "scale", label: "Caustic scale", target: { node: "caust", socket: "scale" }, kind: "float", min: 0.01, max: 1, default: 0.12 },
38
+ { id: "speed", label: "Caustic speed", target: { node: "caust", socket: "speed" }, kind: "float", min: 0, max: 1, default: 0.15 },
39
+ { id: "strength", label: "Caustic strength", target: { node: "caust", socket: "strength" }, kind: "float", min: 0, max: 3, default: 0.6 },
40
+ { id: "fade", label: "Depth fade", target: { node: "caust", socket: "fade" }, kind: "float", min: 1, max: 200, default: 30 },
41
+ ],
42
+ };
@@ -0,0 +1,3 @@
1
+ import type { ShaderGraph } from "../schema";
2
+ export declare const WATER_GRAPH: ShaderGraph;
3
+ //# sourceMappingURL=water.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"water.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/water.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,eAAO,MAAM,WAAW,EAAE,WAgBzB,CAAA"}
@@ -0,0 +1,31 @@
1
+ // Water — a planar reflection, rippled, seen through Fresnel.
2
+ //
3
+ // Put a stage's water materials in a style group carrying this graph and the
4
+ // pool starts reflecting. The reflection itself is the engine's mirror pass,
5
+ // which this is the only graph to read; everything else here is the shaping
6
+ // that keeps it from reading as a mirror laid flat in the floor.
7
+ //
8
+ // The exposed params are the ones worth a slider while judging a shot. Scale
9
+ // and speed are the ripple; a real pool's surface is slow and broad, so both
10
+ // defaults sit low. Tint is the water's own colour — a game rip carries that
11
+ // in its material, and the converter hands it straight over.
12
+ //
13
+ // How see-through the water is belongs to the MATERIAL's alpha, not to this
14
+ // graph, which is where every other group's coverage comes from too.
15
+ export const WATER_GRAPH = {
16
+ version: 1,
17
+ name: "Water",
18
+ tags: ["water", "stage"],
19
+ nodes: [{ id: "water", type: "water" }],
20
+ links: [],
21
+ output: { node: "water", socket: "color" },
22
+ params: [
23
+ { id: "tint", label: "Tint", target: { node: "water", socket: "tint" }, kind: "color", default: [0.04, 0.62, 0.66] },
24
+ { id: "scale", label: "Ripple scale", target: { node: "water", socket: "scale" }, kind: "float", min: 0.01, max: 1, default: 0.18 },
25
+ { id: "speed", label: "Ripple speed", target: { node: "water", socket: "speed" }, kind: "float", min: 0, max: 1, default: 0.12 },
26
+ { id: "strength", label: "Ripple depth", target: { node: "water", socket: "strength" }, kind: "float", min: 0, max: 2, default: 0.7 },
27
+ { id: "blur", label: "Reflection blur", target: { node: "water", socket: "blur" }, kind: "float", min: 0, max: 1, default: 0.25 },
28
+ { id: "mirroring", label: "Mirroring", target: { node: "water", socket: "mirroring" }, kind: "float", min: 0, max: 1, default: 0.20 },
29
+ { id: "sparkle", label: "Sparkle", target: { node: "water", socket: "sparkle" }, kind: "float", min: 0, max: 4, default: 1.0 },
30
+ ],
31
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/graph/registry.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEzD,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,KAAK,CAAA;IACX,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,4FAA4F;IAC5F,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,yFAAyF;IACzF,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACjC,OAAO,EAAE,MAAM,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M,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAC9B,2FAA2F;IAC3F,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAA;IAC/C,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC;sEACkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAYD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,GAAG,MAAM,CAoBhE;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO,CAIpE;AAMD,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAM1D;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKpE;AAsLD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAuzBlD,CAAA"}
@@ -688,11 +688,14 @@ export const NODE_REGISTRY = {
688
688
  occlusion: F(1),
689
689
  emission: C([0, 0, 0]),
690
690
  alpha: F(1),
691
+ /** 1: the lamps' and sun's highlights rise toward white at grazing
692
+ * (Schlick), as Blender's Principled; 0 is URP's fixed reflectance. */
693
+ fresnel: F(0),
691
694
  normal: { type: "vector", contextDefault: "n" },
692
695
  },
693
696
  outputs: { color: "color", alpha: "float" },
694
697
  outputSelect: { color: ".rgb", alpha: ".a" },
695
- emit: (a) => `urp_lit(${a.base_color}, ${a.metallic}, ${a.smoothness}, ${a.specular}, ${a.occlusion}, ${a.emission}, ${a.alpha}, ` +
698
+ emit: (a) => `urp_lit(${a.base_color}, ${a.metallic}, ${a.smoothness}, ${a.specular}, ${a.occlusion}, ${a.emission}, ${a.alpha}, ${a.fresnel}, ` +
696
699
  `${a.normal}, l, v, sun, amb, shadow, input.worldPos, true)`,
697
700
  takesLight: true,
698
701
  },
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, RENDERING_LAYER_DEFAULT, RENDERING_LAYER_CHARACTER, type ModelAttachment, type SceneAovs, type LightProbe, type GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, 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, 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 EffectResult, type ViewLut, type CullDiagnostics, type MidiNote, } 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";
@@ -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,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,QAAQ,GACd,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACvG,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAIzC,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE/C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,QAA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K,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,SAAS,GACf,MAAM,WAAW,CAAA;AAElB;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AACnF,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD;;;;GAIG;AACH,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAC1E,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClF,YAAY,EAAE,YAAY,EAAE,gBAAgB,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"}
@@ -0,0 +1,147 @@
1
+ import { type Rigidbody } from "./types";
2
+ import type { Skinning } from "../model";
3
+ /**
4
+ * Supplementary colliders fitted to the mesh a PMX rigid body fails to cover.
5
+ *
6
+ * PMX body proxies are bodies of revolution — 下半身 is a capsule lying
7
+ * transversely across the hips, so its cross-section is a circle. A pelvis seen
8
+ * from the side is not a circle, and across every rig measured the butt sits
9
+ * 0.18–0.71 units OUTSIDE that capsule while the front is flush or inside. That
10
+ * gap is where a skirt goes through a character: the cloth is resting correctly
11
+ * on the collider it was given, and the collider stops half a unit short of the
12
+ * skin.
13
+ *
14
+ * A rest offset cannot close it (see RigidBodyStore.restOffset) — it is one
15
+ * scalar on a radially symmetric shape, and the error is asymmetric. Measured
16
+ * on 托特's run cycle, the offset that clears the butt is 0.5, which is simply
17
+ * the size of the missing geometry, and at that value the skirt stands off the
18
+ * front and hips by the same 0.5.
19
+ *
20
+ * So fit the missing piece instead: take each bone-following body's own skinned
21
+ * vertices, find the ones that escape its shape in a concentrated lobe, and fit
22
+ * a capsule to that lobe. That is the fix riggers apply by hand, derived from
23
+ * the mesh rather than guessed.
24
+ *
25
+ * Measured on 托特's run cycle, counting butt vertices swallowed by a cloth
26
+ * body: 32.4 per frame with nothing, 30.9 with a 0.02 rest offset, 12.4 with
27
+ * this pass, 10.4 with both.
28
+ */
29
+ export interface AutoFitOptions {
30
+ /** A vertex counts as protruding past this much (model units). Below it the
31
+ * mesh is within authoring tolerance of the proxy and needs no help. */
32
+ minProtrusion?: number;
33
+ /**
34
+ * Ignore vertices further out than this multiple of the source shape's
35
+ * RADIUS (its smallest characteristic dimension).
36
+ *
37
+ * A coarse first cut at keeping hair and loose clothing out — anything
38
+ * standing further off the proxy than the proxy is wide is not skin. The
39
+ * discriminator that actually does the work is minConcentration.
40
+ */
41
+ maxProtrusionRatio?: number;
42
+ /** Fewer protruding vertices than this and it is a spike, not a region. */
43
+ minVertices?: number;
44
+ /**
45
+ * Per-axis quantile the fitted lobe's extent is clipped to, each end. A
46
+ * handful of stray vertices (a weight-painting slip, a seam) would otherwise
47
+ * stretch the capsule far past the surface everyone can see.
48
+ */
49
+ quantile?: number;
50
+ /** Skip the fit unless the capsule actually reaches this far past what is
51
+ * already covered — otherwise it adds solver rows for nothing. */
52
+ minGain?: number;
53
+ /** How tightly the kept lobe's outward directions must agree, 0–1. A loose
54
+ * sanity check; the real discriminator is minConcentration. */
55
+ minDirectionality?: number;
56
+ /** Vertices outside the dominant lobe, by this cosine, are not part of the
57
+ * feature being fitted. */
58
+ lobeCos?: number;
59
+ /**
60
+ * How much deeper the fitted lobe must be than protrusion typically is on
61
+ * this body, averaged over the vertices that protrude at all.
62
+ *
63
+ * This is the guard that separates "the proxy is missing a lobe" from "the
64
+ * proxy is not a proxy for this mesh at all". A pelvis escapes its capsule by
65
+ * 0.53 at the back and 0.14 at the front, so the back lobe stands well clear
66
+ * of the average. Hair escapes the skull by a similar depth in every
67
+ * direction, so its deepest lobe is no deeper than typical and the ratio sits
68
+ * near 1. See the note at the meanProtrusion computation for what this
69
+ * deliberately refuses to fit.
70
+ *
71
+ * Without it the pass fits the hairstyle — measured on 托特, 頭 reports
72
+ * 3653 of 4669 vertices outside its capsule, and the fitted shape was a crate
73
+ * around the whole head. No threshold on depth or vertex count tells those
74
+ * two cases apart; concentration does.
75
+ */
76
+ minConcentration?: number;
77
+ /**
78
+ * How many capsules may be fitted to one body, each against what the previous
79
+ * ones already cover.
80
+ *
81
+ * One capsule inscribed in a lobe does not fill it — on 托特's butt a single
82
+ * fit removed 58% of the clipping and left the rest at the edges the capsule
83
+ * could not reach. Each further pass re-measures protrusion against the
84
+ * original shape UNION everything fitted so far, so it lands on whatever is
85
+ * still exposed instead of re-fitting the same bulge.
86
+ */
87
+ maxShapesPerBody?: number;
88
+ /**
89
+ * Quantile of the lobe's perpendicular spread used as the capsule radius.
90
+ *
91
+ * The clip-versus-float dial, and the one to reach for if a result looks
92
+ * wrong. Lower hugs the body: less standoff in idle, more clipping left. 1.0
93
+ * encloses the lobe entirely, which is what produced a visibly hovering
94
+ * skirt on 托特.
95
+ */
96
+ radiusQuantile?: number;
97
+ /**
98
+ * Fit only the deepest part of each lobe: points at least this fraction of
99
+ * the lobe's own maximum protrusion.
100
+ *
101
+ * A lobe tapers to nothing at its edges, and a capsule sized to span the
102
+ * whole thing has to be fat enough to reach the edges too. Fitting the deep
103
+ * core keeps each capsule small and lets a later pass handle the shallows
104
+ * with its own, which is both tighter and closer to what the surface is
105
+ * actually doing.
106
+ */
107
+ lobeDepthFraction?: number;
108
+ }
109
+ /** What the pass decided for one source body — surfaced so a rig can be
110
+ * inspected rather than silently rebuilt underneath its author. */
111
+ export interface AutoFitResult {
112
+ /** Index of the body in the input array that this supplements. */
113
+ sourceIndex: number;
114
+ sourceName: string;
115
+ /** Vertices dominated by that body's bone, and how many were outside it. */
116
+ vertexCount: number;
117
+ protrudingCount: number;
118
+ /** Furthest any kept vertex sat outside the source shape. */
119
+ maxProtrusion: number;
120
+ /** How far the fitted capsule reaches past what was already covered. */
121
+ gain: number;
122
+ /** Length of the kept lobe's mean outward direction, 0–1. */
123
+ directionality: number;
124
+ /** Lobe depth over the body's average protrusion. See minConcentration. */
125
+ concentration: number;
126
+ /**
127
+ * Furthest the capsule's newly exposed surface sits from the skin it was
128
+ * fitted to — the amount cloth resting on it will stand off the body at the
129
+ * worst point, and the number to watch if a result looks puffy. Only the part
130
+ * reaching outside the source shape is measured; the rest is buried.
131
+ */
132
+ overshoot: number;
133
+ body: Rigidbody;
134
+ }
135
+ /**
136
+ * Fit supplementary colliders for every bone-following body whose own mesh
137
+ * escapes it.
138
+ *
139
+ * `vertices` is the model's interleaved vertex buffer (stride 8, position
140
+ * first) and `skinning` its joints/weights — both in PMX bind pose, the same
141
+ * space as `shapePosition` / `shapeRotation`, so nothing has to be skinned.
142
+ *
143
+ * Returns one entry per body it chose to supplement; the caller appends
144
+ * `.body` to the rigid body list before constructing RezePhysics.
145
+ */
146
+ export declare function fitSupplementaryColliders(rigidbodies: Rigidbody[], vertices: Float32Array, skinning: Skinning, options?: AutoFitOptions): AutoFitResult[];
147
+ //# sourceMappingURL=autofit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autofit.d.ts","sourceRoot":"","sources":["../../src/physics/autofit.ts"],"names":[],"mappings":"AACA,OAAO,EAAiC,KAAK,SAAS,EAAE,MAAM,SAAS,CAAA;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,cAAc;IAC7B;6EACyE;IACzE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,2E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