reze-engine 0.68.1 → 0.68.2

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 (50) hide show
  1. package/dist/_dbg-loader.mjs +1100 -0
  2. package/dist/engine.d.ts +100 -0
  3. package/dist/engine.d.ts.map +1 -1
  4. package/dist/engine.js +194 -2
  5. package/dist/index.d.ts +3 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +2 -0
  8. package/dist/shaders/passes/aov.d.ts +37 -0
  9. package/dist/shaders/passes/aov.d.ts.map +1 -0
  10. package/dist/shaders/passes/aov.js +180 -0
  11. package/package.json +1 -1
  12. package/src/engine.ts +229 -2
  13. package/src/index.ts +4 -0
  14. package/src/shaders/passes/aov.ts +187 -0
  15. package/dist/graph/presets/pool_floor.d.ts +0 -3
  16. package/dist/graph/presets/pool_floor.d.ts.map +0 -1
  17. package/dist/graph/presets/pool_floor.js +0 -42
  18. package/dist/graph/presets/water.d.ts +0 -3
  19. package/dist/graph/presets/water.d.ts.map +0 -1
  20. package/dist/graph/presets/water.js +0 -31
  21. package/dist/physics/autofit.d.ts +0 -147
  22. package/dist/physics/autofit.d.ts.map +0 -1
  23. package/dist/physics/autofit.js +0 -501
  24. package/dist/shaders/agx-lut.d.ts +0 -11
  25. package/dist/shaders/agx-lut.d.ts.map +0 -1
  26. package/dist/shaders/agx-lut.js +0 -29
  27. package/dist/shaders/dfg_lut.d.ts +0 -3
  28. package/dist/shaders/dfg_lut.d.ts.map +0 -1
  29. package/dist/shaders/dfg_lut.js +0 -129
  30. package/dist/shaders/ltc_mag_lut.d.ts +0 -3
  31. package/dist/shaders/ltc_mag_lut.d.ts.map +0 -1
  32. package/dist/shaders/ltc_mag_lut.js +0 -1033
  33. package/dist/shaders/passes/field-blit.d.ts +0 -26
  34. package/dist/shaders/passes/field-blit.d.ts.map +0 -1
  35. package/dist/shaders/passes/field-blit.js +0 -65
  36. package/dist/shaders/passes/ghosts.d.ts +0 -22
  37. package/dist/shaders/passes/ghosts.d.ts.map +0 -1
  38. package/dist/shaders/passes/ghosts.js +0 -75
  39. package/dist/shaders/passes/ground-noise.d.ts +0 -7
  40. package/dist/shaders/passes/ground-noise.d.ts.map +0 -1
  41. package/dist/shaders/passes/ground-noise.js +0 -88
  42. package/dist/shaders/passes/sim.d.ts +0 -34
  43. package/dist/shaders/passes/sim.d.ts.map +0 -1
  44. package/dist/shaders/passes/sim.js +0 -169
  45. package/dist/shaders/score-api.d.ts +0 -10
  46. package/dist/shaders/score-api.d.ts.map +0 -1
  47. package/dist/shaders/score-api.js +0 -114
  48. package/dist/shaders/shadow-api.d.ts +0 -29
  49. package/dist/shaders/shadow-api.d.ts.map +0 -1
  50. package/dist/shaders/shadow-api.js +0 -112
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 GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, type EffectResult, 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 GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, type EffectResult, 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";
@@ -59,4 +59,6 @@ export type { EyeTrackingOptions } from "./model";
59
59
  export type { NativeStagePackage, NativeStageReader } from "./unity/stage";
60
60
  export type { NativeLook, NativeMaterialSpec, NativeTexture } from "./unity/looks";
61
61
  export type { NativeShader, NativeShaderInfo } from "./unity/host";
62
+ export { AOV_PIXEL_FIELDS, AOV_PIXEL_STRIDE } from "./shaders/passes/aov";
63
+ export { GROUND_MATERIAL_ID, GROUND_OBJECT_ID } from "./shaders/passes/ground";
62
64
  //# sourceMappingURL=index.d.ts.map
@@ -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,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK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rB,oBAAoB,EACpB,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,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;AAEjD;;;;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"}
package/dist/index.js CHANGED
@@ -66,3 +66,5 @@ export { boneOverlay, boneMarkerPositions, rigidbodyOverlay, jointOverlay, build
66
66
  * Pure strings, no GPU: importing them costs a host nothing.
67
67
  */
68
68
  export { EFFECT_MATH_API, PARTICLE_STRUCT_WGSL } from "./shaders/passes/hosted-api";
69
+ export { AOV_PIXEL_FIELDS, AOV_PIXEL_STRIDE } from "./shaders/passes/aov";
70
+ export { GROUND_MATERIAL_ID, GROUND_OBJECT_ID } from "./shaders/passes/ground";
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The frame, read back as numbers — what an agent (or a test) measures instead
3
+ * of squinting at a picture.
4
+ *
5
+ * A screenshot answers "what does it look like". It cannot answer the questions
6
+ * a lighting artist actually asks of a render: is her face in the sun's shadow,
7
+ * which lamp is carrying the key, how many stops over is that highlight, which
8
+ * pixels are skin. Every one of those is a number the frame already computed
9
+ * and threw away; these passes keep them.
10
+ *
11
+ * TWO ENTRY POINTS over one prelude:
12
+ *
13
+ * pixels — one invocation per texel of the frame just rendered. Reads the id
14
+ * attachment, the depth and the linear HDR resolve, rebuilds the
15
+ * world point from the depth and a normal from its neighbours, and
16
+ * asks the same shadow atlas and lamp records the materials asked.
17
+ * probe — the same light questions at points the caller names (a bone, a
18
+ * face), with each lamp's share kept apart.
19
+ *
20
+ * The normal is RECONSTRUCTED from depth, not the one the material shaded
21
+ * with: the frame never stores normals, and storing them for every frame to
22
+ * serve an occasional readback would be the cost the id attachment's
23
+ * store-only-when-read rule exists to avoid. On a silhouette edge it is the
24
+ * flatter of the two neighbours, which is right for every texel that is not
25
+ * the edge itself.
26
+ */
27
+ /** Floats per texel in the pixels output — see PIXEL_FIELDS. */
28
+ export declare const AOV_PIXEL_STRIDE = 12;
29
+ /** What each of a texel's floats is, in order. */
30
+ export declare const AOV_PIXEL_FIELDS: readonly ["r", "g", "b", "depth", "sunShadow", "sunFacing", "lampR", "lampG", "lampB", "ambR", "ambG", "ambB"];
31
+ /** Floats per probe point before its per-lamp block. */
32
+ export declare const AOV_PROBE_HEAD = 12;
33
+ /** Floats per probe point: the head, then rgb+pad for every lamp slot. */
34
+ export declare const AOV_PROBE_STRIDE: number;
35
+ export declare const AOV_PIXELS_WGSL: string;
36
+ export declare const AOV_PROBE_WGSL: string;
37
+ //# sourceMappingURL=aov.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aov.d.ts","sourceRoot":"","sources":["../../../src/shaders/passes/aov.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,KAAK,CAAA;AAElC,kDAAkD;AAClD,eAAO,MAAM,gBAAgB,gHAOnB,CAAA;AAEV,wDAAwD;AACxD,eAAO,MAAM,cAAc,KAAK,CAAA;AAChC,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,QAAkC,CAAA;AAqB/D,eAAO,MAAM,eAAe,QA6E3B,CAAA;AAED,eAAO,MAAM,cAAc,QAwC1B,CAAA"}
@@ -0,0 +1,180 @@
1
+ import { sceneLightApi } from "../scene-light-api";
2
+ import { lightsApi, MAX_LIGHTS } from "../lights";
3
+ /**
4
+ * The frame, read back as numbers — what an agent (or a test) measures instead
5
+ * of squinting at a picture.
6
+ *
7
+ * A screenshot answers "what does it look like". It cannot answer the questions
8
+ * a lighting artist actually asks of a render: is her face in the sun's shadow,
9
+ * which lamp is carrying the key, how many stops over is that highlight, which
10
+ * pixels are skin. Every one of those is a number the frame already computed
11
+ * and threw away; these passes keep them.
12
+ *
13
+ * TWO ENTRY POINTS over one prelude:
14
+ *
15
+ * pixels — one invocation per texel of the frame just rendered. Reads the id
16
+ * attachment, the depth and the linear HDR resolve, rebuilds the
17
+ * world point from the depth and a normal from its neighbours, and
18
+ * asks the same shadow atlas and lamp records the materials asked.
19
+ * probe — the same light questions at points the caller names (a bone, a
20
+ * face), with each lamp's share kept apart.
21
+ *
22
+ * The normal is RECONSTRUCTED from depth, not the one the material shaded
23
+ * with: the frame never stores normals, and storing them for every frame to
24
+ * serve an occasional readback would be the cost the id attachment's
25
+ * store-only-when-read rule exists to avoid. On a silhouette edge it is the
26
+ * flatter of the two neighbours, which is right for every texel that is not
27
+ * the edge itself.
28
+ */
29
+ /** Floats per texel in the pixels output — see PIXEL_FIELDS. */
30
+ export const AOV_PIXEL_STRIDE = 12;
31
+ /** What each of a texel's floats is, in order. */
32
+ export const AOV_PIXEL_FIELDS = [
33
+ "r", "g", "b", // linear HDR, before exposure and the view transform
34
+ "depth", // distance from the eye, world units; 0 where nothing drew
35
+ "sunShadow", // 1 lit, 0 in a caster's shadow; -1 where nothing drew
36
+ "sunFacing", // N·L toward the sun, -1..1 (the toon ramp's input)
37
+ "lampR", "lampG", "lampB", // every positional lamp's light arriving here
38
+ "ambR", "ambG", "ambB", // the world's light arriving here
39
+ ];
40
+ /** Floats per probe point before its per-lamp block. */
41
+ export const AOV_PROBE_HEAD = 12;
42
+ /** Floats per probe point: the head, then rgb+pad for every lamp slot. */
43
+ export const AOV_PROBE_STRIDE = AOV_PROBE_HEAD + MAX_LIGHTS * 4;
44
+ // Bindings 0..3 are the scene light API, 4..6 the lamps and their cookies.
45
+ const PRELUDE = /* wgsl */ `
46
+ ${sceneLightApi(true, 0, 0)}
47
+ ${lightsApi(0, 4, "0xffffffffu", { binding: 5, sampler: "_aovSampler" })}
48
+ @group(0) @binding(6) var _aovSampler: sampler;
49
+
50
+ /** The sun's cast shadow at p, nudged along n off the surface — the
51
+ * materials' rzSunOcclusion, without the facing test (sunFacing carries it). */
52
+ fn aovSunShadow(p: vec3f, n: vec3f) -> f32 {
53
+ let castAmt = _rzLight.lights[0].direction.w;
54
+ if (castAmt <= 0.0) { return 1.0; }
55
+ let a = _rzSunLocate(p + n * 0.08);
56
+ if (a.w < 0.0) { return 1.0; }
57
+ return mix(1.0, _rzSunTaps(a), castAmt);
58
+ }
59
+
60
+ fn aovToSun() -> vec3f { return normalize(-_rzLight.lights[0].direction.xyz); }
61
+ `;
62
+ export const AOV_PIXELS_WGSL = /* wgsl */ `
63
+ ${PRELUDE}
64
+ @group(0) @binding(7) var idTex: texture_multisampled_2d<u32>;
65
+ @group(0) @binding(8) var depthTex: texture_depth_multisampled_2d;
66
+ @group(0) @binding(9) var hdrTex: texture_2d<f32>;
67
+ struct AovU { invViewProj: mat4x4f, eye: vec4f, size: vec4u, }
68
+ @group(0) @binding(10) var<uniform> u: AovU;
69
+ @group(0) @binding(11) var<storage, read_write> outF: array<f32>;
70
+ @group(0) @binding(12) var<storage, read_write> outId: array<u32>;
71
+
72
+ fn worldAt(c: vec2i, z: f32) -> vec3f {
73
+ let uv = (vec2f(c) + 0.5) / vec2f(u.size.xy);
74
+ let h = u.invViewProj * vec4f(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, z, 1.0);
75
+ return h.xyz / h.w;
76
+ }
77
+
78
+ fn drawn(c: vec2i) -> bool {
79
+ if (any(c < vec2i(0)) || any(c >= vec2i(u.size.xy))) { return false; }
80
+ let id = textureLoad(idTex, c, 0).xy;
81
+ return id.x != 0u || id.y != 0u;
82
+ }
83
+
84
+ /** The step from p to the neighbour at c + d (or c - d, negated), whichever is
85
+ * nearer in depth: across a silhouette the far neighbour belongs to something
86
+ * else, and a normal built from it tilts toward the background. */
87
+ fn tangent(c: vec2i, d: vec2i, p: vec3f) -> vec3f {
88
+ let a = c + d;
89
+ let b = c - d;
90
+ let okA = drawn(a);
91
+ let okB = drawn(b);
92
+ var ta = vec3f(0.0);
93
+ var tb = vec3f(0.0);
94
+ if (okA) { ta = worldAt(a, textureLoad(depthTex, a, 0)) - p; }
95
+ if (okB) { tb = p - worldAt(b, textureLoad(depthTex, b, 0)); }
96
+ if (okA && okB) { return select(tb, ta, dot(ta, ta) <= dot(tb, tb)); }
97
+ if (okA) { return ta; }
98
+ return tb;
99
+ }
100
+
101
+ @compute @workgroup_size(8, 8)
102
+ fn pixels(@builtin(global_invocation_id) gid: vec3u) {
103
+ if (gid.x >= u.size.x || gid.y >= u.size.y) { return; }
104
+ let c = vec2i(gid.xy);
105
+ let i = gid.y * u.size.x + gid.x;
106
+ let o = i * ${AOV_PIXEL_STRIDE}u;
107
+ let id = textureLoad(idTex, c, 0).xy;
108
+ let rgb = textureLoad(hdrTex, c, 0).rgb;
109
+ // Material in the low half, object in the high — the attachment's own order
110
+ // (scene-contract: vec2u(material, object)).
111
+ outId[i] = (id.y << 16u) | (id.x & 0xffffu);
112
+ outF[o] = rgb.r;
113
+ outF[o + 1u] = rgb.g;
114
+ outF[o + 2u] = rgb.b;
115
+ for (var k = 3u; k < ${AOV_PIXEL_STRIDE}u; k++) { outF[o + k] = 0.0; }
116
+ if (id.x == 0u && id.y == 0u) {
117
+ outF[o + 4u] = -1.0;
118
+ return;
119
+ }
120
+ let p = worldAt(c, textureLoad(depthTex, c, 0));
121
+ var n = cross(tangent(c, vec2i(0, 1), p), tangent(c, vec2i(1, 0), p));
122
+ let toEye = u.eye.xyz - p;
123
+ if (dot(n, n) < 1e-12) { n = toEye; }
124
+ n = normalize(n);
125
+ // Toward the eye: the side of the surface this texel shows.
126
+ if (dot(n, toEye) < 0.0) { n = -n; }
127
+ let lamps = rzLightsDiffuse(p, n);
128
+ let amb = rzWorldAmbient(n);
129
+ outF[o + 3u] = length(toEye);
130
+ outF[o + 4u] = aovSunShadow(p, n);
131
+ outF[o + 5u] = dot(n, aovToSun());
132
+ outF[o + 6u] = lamps.r;
133
+ outF[o + 7u] = lamps.g;
134
+ outF[o + 8u] = lamps.b;
135
+ outF[o + 9u] = amb.r;
136
+ outF[o + 10u] = amb.g;
137
+ outF[o + 11u] = amb.b;
138
+ }
139
+ `;
140
+ export const AOV_PROBE_WGSL = /* wgsl */ `
141
+ ${PRELUDE}
142
+ struct ProbePoint { p: vec4f, n: vec4f, }
143
+ @group(0) @binding(7) var<storage, read> points: array<ProbePoint>;
144
+ @group(0) @binding(8) var<storage, read_write> outF: array<f32>;
145
+
146
+ @compute @workgroup_size(1)
147
+ fn probe(@builtin(global_invocation_id) gid: vec3u) {
148
+ let i = gid.x;
149
+ if (i >= arrayLength(&points)) { return; }
150
+ let p = points[i].p.xyz;
151
+ let n = normalize(points[i].n.xyz);
152
+ let o = i * ${AOV_PROBE_STRIDE}u;
153
+ // Colour and strength travel apart in the light uniform (writeSun); the
154
+ // light arriving is their product.
155
+ let sun = _rzLight.lights[0].color.rgb * _rzLight.lights[0].color.w;
156
+ let amb = rzWorldAmbient(n);
157
+ outF[o] = aovSunShadow(p, n);
158
+ outF[o + 1u] = dot(n, aovToSun());
159
+ outF[o + 2u] = sun.r;
160
+ outF[o + 3u] = sun.g;
161
+ outF[o + 4u] = sun.b;
162
+ outF[o + 5u] = amb.r;
163
+ outF[o + 6u] = amb.g;
164
+ outF[o + 7u] = amb.b;
165
+ let count = rzLightCount();
166
+ outF[o + 8u] = f32(count);
167
+ // The document's lamps come first (setLights order); the rest are effects'.
168
+ outF[o + 9u] = f32(_rzLightDocCount());
169
+ for (var k = 10u; k < ${AOV_PROBE_HEAD}u; k++) { outF[o + k] = 0.0; }
170
+ for (var l = 0u; l < ${MAX_LIGHTS}u; l++) {
171
+ var c = vec3f(0.0);
172
+ if (l < count) { c = _rzLightOne(l, p, n); }
173
+ let b = o + ${AOV_PROBE_HEAD}u + l * 4u;
174
+ outF[b] = c.r;
175
+ outF[b + 1u] = c.g;
176
+ outF[b + 2u] = c.b;
177
+ outF[b + 3u] = 0.0;
178
+ }
179
+ }
180
+ `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reze-engine",
3
- "version": "0.68.1",
3
+ "version": "0.68.2",
4
4
  "description": "A lightweight WebGPU engine for real-time 3D MMD/PMX model rendering",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/src/engine.ts CHANGED
@@ -27,6 +27,7 @@ import {
27
27
  } from "./asset-reader"
28
28
  import { SHADOW_DEPTH_SHADER_WGSL } from "./shaders/passes/shadow"
29
29
  import { ID_DEBUG_SHADER_WGSL } from "./shaders/passes/id-debug"
30
+ import { AOV_PIXELS_WGSL, AOV_PIXEL_FIELDS, AOV_PIXEL_STRIDE, AOV_PROBE_HEAD, AOV_PROBE_STRIDE, AOV_PROBE_WGSL } from "./shaders/passes/aov"
30
31
  import { paramChanged, sampleParamTrack, type ParamKey, type ParamValue } from "./param-track"
31
32
  import {
32
33
  advanceSim,
@@ -471,6 +472,38 @@ export type ModelTransform = {
471
472
  }
472
473
 
473
474
  /** How a model rides another — MMD's 外部親 (outside parent). See setModelParent. */
475
+ /**
476
+ * The frame read back as numbers (Engine.readAovs). `data` holds `stride`
477
+ * floats per texel, row-major from the top-left, named by `fields`; `ids` one
478
+ * word per texel, material id in the low 16 bits and object id in the high
479
+ * (Engine.getIdLegend names them; 0 is nothing). Colour is LINEAR and before
480
+ * `exposure` (stops) is applied.
481
+ */
482
+ export type SceneAovs = {
483
+ width: number
484
+ height: number
485
+ stride: number
486
+ fields: typeof AOV_PIXEL_FIELDS
487
+ data: Float32Array
488
+ ids: Uint32Array
489
+ exposure: number
490
+ }
491
+
492
+ /** The light arriving at one point (Engine.probeLight). Colours are linear
493
+ * light, before the surface's albedo: the sun's is its colour times strength,
494
+ * unshadowed and unfaced — multiply by sunShadow and max(sunFacing, 0). */
495
+ export type LightProbe = {
496
+ sunShadow: number
497
+ sunFacing: number
498
+ sun: [number, number, number]
499
+ ambient: [number, number, number]
500
+ /** Each lamp's light here, in the engine's lamp order. */
501
+ lamps: [number, number, number][]
502
+ /** How many of `lamps` are the document's (setLights, non-directional, in
503
+ * order); the rest an effect emits. */
504
+ documentLamps: number
505
+ }
506
+
474
507
  export type ModelAttachment = {
475
508
  /** Model key of the parent. */
476
509
  model: string
@@ -2279,6 +2312,11 @@ export class Engine {
2279
2312
  private idDebugBindGroupLayout: GPUBindGroupLayout | null = null
2280
2313
  private idDebugBindGroup: GPUBindGroup | null = null
2281
2314
  private idDebug = false
2315
+ /** Store ids and depth for readAovs — see setAovCapture. */
2316
+ private aovCapture = false
2317
+ private aovPixelsPipeline: GPUComputePipeline | null = null
2318
+ private aovProbePipeline: GPUComputePipeline | null = null
2319
+ private aovSampler: GPUSampler | null = null
2282
2320
  private multisampleMaskTexture!: GPUTexture
2283
2321
  private maskResolveTexture!: GPUTexture
2284
2322
  private maskResolveView!: GPUTextureView
@@ -3425,6 +3463,189 @@ export class Engine {
3425
3463
  return this.idView !== null
3426
3464
  }
3427
3465
 
3466
+ /**
3467
+ * Keep the frame's ids and depth for readAovs.
3468
+ *
3469
+ * Both are discarded at the end of an ordinary frame (see the store ops in
3470
+ * renderFrame); while this is on they are stored, on exactly the terms the
3471
+ * id-debug view and a masking effect already get. Turn it on, render the
3472
+ * frame to measure, read it, turn it off — the stores cost real bandwidth
3473
+ * and nothing else reads them.
3474
+ *
3475
+ * Returns false when the device has no id attachment, in which case
3476
+ * readAovs answers null.
3477
+ */
3478
+ setAovCapture(on: boolean): boolean {
3479
+ this.aovCapture = on && this.idView !== null
3480
+ return this.aovCapture || !on
3481
+ }
3482
+
3483
+ /**
3484
+ * What drew each id: the model's object id, and its materials' ids in the
3485
+ * order the id attachment counts them (materials that produced a draw,
3486
+ * 1-based). The floor is GROUND_OBJECT_ID / GROUND_MATERIAL_ID.
3487
+ */
3488
+ getIdLegend(): { objectId: number; model: string; materials: { id: number; name: string }[] }[] {
3489
+ const out: { objectId: number; model: string; materials: { id: number; name: string }[] }[] = []
3490
+ for (const [name, inst] of this.modelInstances) {
3491
+ const materials: { id: number; name: string }[] = []
3492
+ let id = 0
3493
+ for (const mat of inst.model.getMaterials()) {
3494
+ if (mat.vertexCount === 0) continue
3495
+ materials.push({ id: ++id, name: mat.name })
3496
+ }
3497
+ out.push({ objectId: inst.objectId, model: name, materials })
3498
+ }
3499
+ return out
3500
+ }
3501
+
3502
+ /**
3503
+ * The last frame, as numbers: per texel its linear colour, what drew it, how
3504
+ * far it is, and the light arriving there — the sun's shadow and facing, the
3505
+ * lamps', the world's. See shaders/passes/aov.ts for what each field is and
3506
+ * how the normal is rebuilt.
3507
+ *
3508
+ * Reads the frame ALREADY RENDERED, at the render size it was rendered at:
3509
+ * call it after renderFrame with setAovCapture on, before anything renders
3510
+ * again (a capture stops the loop for exactly this). Null when the device
3511
+ * has no id attachment or capture was not on.
3512
+ */
3513
+ async readAovs(): Promise<SceneAovs | null> {
3514
+ if (!this.aovCapture || !this.idView || !this.depthReadView || !this.camera) return null
3515
+ const width = this.hdrResolveTexture.width
3516
+ const height = this.hdrResolveTexture.height
3517
+ const pipeline = this.aovPixelsPipeline ??= this.device.createComputePipeline({
3518
+ label: "aov pixels",
3519
+ layout: "auto",
3520
+ compute: { module: this.device.createShaderModule({ label: "aov pixels", code: AOV_PIXELS_WGSL }), entryPoint: "pixels" },
3521
+ })
3522
+
3523
+ const invVP = this.camera.getProjectionMatrix().multiply(this.camera.getViewMatrix()).inverse().values
3524
+ const eye = this.camera.getPosition()
3525
+ const uniform = new ArrayBuffer(64 + 16 + 16)
3526
+ new Float32Array(uniform, 0, 16).set(invVP)
3527
+ new Float32Array(uniform, 64, 4).set([eye.x, eye.y, eye.z, 1])
3528
+ new Uint32Array(uniform, 80, 4).set([width, height, 0, 0])
3529
+ const ubuf = this.device.createBuffer({ label: "aov uniforms", size: uniform.byteLength, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST })
3530
+ this.device.queue.writeBuffer(ubuf, 0, uniform)
3531
+
3532
+ const texels = width * height
3533
+ const fBytes = texels * AOV_PIXEL_STRIDE * 4
3534
+ const idBytes = texels * 4
3535
+ const fBuf = this.device.createBuffer({ label: "aov out", size: fBytes, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC })
3536
+ const idBuf = this.device.createBuffer({ label: "aov ids", size: idBytes, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC })
3537
+ const fRead = this.device.createBuffer({ label: "aov out read", size: fBytes, usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST })
3538
+ const idRead = this.device.createBuffer({ label: "aov ids read", size: idBytes, usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST })
3539
+
3540
+ const bind = this.device.createBindGroup({
3541
+ label: "aov pixels",
3542
+ layout: pipeline.getBindGroupLayout(0),
3543
+ entries: [
3544
+ ...this.aovLightEntries(),
3545
+ { binding: 7, resource: this.idView },
3546
+ { binding: 8, resource: this.depthReadView },
3547
+ { binding: 9, resource: this.hdrResolveTexture.createView() },
3548
+ { binding: 10, resource: { buffer: ubuf } },
3549
+ { binding: 11, resource: { buffer: fBuf } },
3550
+ { binding: 12, resource: { buffer: idBuf } },
3551
+ ],
3552
+ })
3553
+ const encoder = this.device.createCommandEncoder({ label: "aov pixels" })
3554
+ const pass = encoder.beginComputePass({ label: "aov pixels" })
3555
+ pass.setPipeline(pipeline)
3556
+ pass.setBindGroup(0, bind)
3557
+ pass.dispatchWorkgroups(Math.ceil(width / 8), Math.ceil(height / 8))
3558
+ pass.end()
3559
+ encoder.copyBufferToBuffer(fBuf, 0, fRead, 0, fBytes)
3560
+ encoder.copyBufferToBuffer(idBuf, 0, idRead, 0, idBytes)
3561
+ this.device.queue.submit([encoder.finish()])
3562
+
3563
+ try {
3564
+ await Promise.all([fRead.mapAsync(GPUMapMode.READ), idRead.mapAsync(GPUMapMode.READ)])
3565
+ const f = new Float32Array(fRead.getMappedRange().slice(0))
3566
+ const ids = new Uint32Array(idRead.getMappedRange().slice(0))
3567
+ const exposure = this.getViewTransformOptions().exposure ?? 0
3568
+ return { width, height, stride: AOV_PIXEL_STRIDE, fields: AOV_PIXEL_FIELDS, data: f, ids, exposure }
3569
+ } finally {
3570
+ for (const b of [ubuf, fBuf, idBuf, fRead, idRead]) b.destroy()
3571
+ }
3572
+ }
3573
+
3574
+ /**
3575
+ * The light arriving at points the caller names — a face, a hand, a spot on
3576
+ * the floor — facing the normal given: the sun's shadow, facing and colour,
3577
+ * the world's ambient, and EACH LAMP'S share kept apart, in the order the
3578
+ * engine holds them (the document's lamps first, as setLights got them,
3579
+ * then any an effect emits).
3580
+ *
3581
+ * Reads the shadow atlas and lamp records of the last frame rendered.
3582
+ */
3583
+ async probeLight(points: readonly { position: { x: number; y: number; z: number }; normal: { x: number; y: number; z: number } }[]): Promise<LightProbe[]> {
3584
+ if (points.length === 0) return []
3585
+ const pipeline = this.aovProbePipeline ??= this.device.createComputePipeline({
3586
+ label: "aov probe",
3587
+ layout: "auto",
3588
+ compute: { module: this.device.createShaderModule({ label: "aov probe", code: AOV_PROBE_WGSL }), entryPoint: "probe" },
3589
+ })
3590
+ const data = new Float32Array(points.length * 8)
3591
+ points.forEach((pt, i) => data.set([pt.position.x, pt.position.y, pt.position.z, 1, pt.normal.x, pt.normal.y, pt.normal.z, 0], i * 8))
3592
+ const inBuf = this.device.createBuffer({ label: "aov probe points", size: data.byteLength, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST })
3593
+ this.device.queue.writeBuffer(inBuf, 0, data)
3594
+ const outBytes = points.length * AOV_PROBE_STRIDE * 4
3595
+ const outBuf = this.device.createBuffer({ label: "aov probe out", size: outBytes, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC })
3596
+ const readBuf = this.device.createBuffer({ label: "aov probe read", size: outBytes, usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST })
3597
+ const bind = this.device.createBindGroup({
3598
+ label: "aov probe",
3599
+ layout: pipeline.getBindGroupLayout(0),
3600
+ entries: [...this.aovLightEntries(), { binding: 7, resource: { buffer: inBuf } }, { binding: 8, resource: { buffer: outBuf } }],
3601
+ })
3602
+ const encoder = this.device.createCommandEncoder({ label: "aov probe" })
3603
+ const pass = encoder.beginComputePass({ label: "aov probe" })
3604
+ pass.setPipeline(pipeline)
3605
+ pass.setBindGroup(0, bind)
3606
+ pass.dispatchWorkgroups(points.length)
3607
+ pass.end()
3608
+ encoder.copyBufferToBuffer(outBuf, 0, readBuf, 0, outBytes)
3609
+ this.device.queue.submit([encoder.finish()])
3610
+ try {
3611
+ await readBuf.mapAsync(GPUMapMode.READ)
3612
+ const f = new Float32Array(readBuf.getMappedRange().slice(0))
3613
+ return points.map((_, i) => {
3614
+ const o = i * AOV_PROBE_STRIDE
3615
+ const count = Math.round(f[o + 8])
3616
+ const lamps: [number, number, number][] = []
3617
+ for (let l = 0; l < count; l++) {
3618
+ const b = o + AOV_PROBE_HEAD + l * 4
3619
+ lamps.push([f[b], f[b + 1], f[b + 2]])
3620
+ }
3621
+ return {
3622
+ sunShadow: f[o],
3623
+ sunFacing: f[o + 1],
3624
+ sun: [f[o + 2], f[o + 3], f[o + 4]],
3625
+ ambient: [f[o + 5], f[o + 6], f[o + 7]],
3626
+ lamps,
3627
+ documentLamps: Math.round(f[o + 9]),
3628
+ }
3629
+ })
3630
+ } finally {
3631
+ for (const b of [inBuf, outBuf, readBuf]) b.destroy()
3632
+ }
3633
+ }
3634
+
3635
+ /** The scene light API and the lamps, as aov.ts's prelude binds them. */
3636
+ private aovLightEntries(): GPUBindGroupEntry[] {
3637
+ this.aovSampler ??= this.device.createSampler({ label: "aov cookie sampler", magFilter: "linear", minFilter: "linear" })
3638
+ return [
3639
+ { binding: 0, resource: { buffer: this.lightUniformBuffer } },
3640
+ { binding: 1, resource: { buffer: this.shadowLightVPBuffer } },
3641
+ { binding: 2, resource: this.shadowAtlasView },
3642
+ { binding: 3, resource: this.shadowComparisonSampler },
3643
+ { binding: 4, resource: { buffer: this.lightsBuffer } },
3644
+ { binding: 5, resource: this.cookieView },
3645
+ { binding: 6, resource: this.aovSampler },
3646
+ ]
3647
+ }
3648
+
3428
3649
  /** The pass that draws it, built lazily so a scene that never asks for the
3429
3650
  * debug view never compiles it. */
3430
3651
  private ensureIdDebugPipeline(): boolean {
@@ -7098,6 +7319,12 @@ export class Engine {
7098
7319
  * frame. Nothing recompiles, so this is safe to drive per frame from a
7099
7320
  * timeline.
7100
7321
  */
7322
+ /** How many effects are installed — the indices setEffectInfluence and its
7323
+ * siblings address are 0 up to this. */
7324
+ getEffectCount(): number {
7325
+ return this.effects.length
7326
+ }
7327
+
7101
7328
  setEffectInfluence(index: number, influence: number): void {
7102
7329
  const fx = this.effects[index]
7103
7330
  if (!fx) return
@@ -17246,7 +17473,7 @@ export class Engine {
17246
17473
  // The scattering pass is the third reader: it rejects taps across a depth
17247
17474
  // step and scales its width by distance, so a scene wearing a subsurface
17248
17475
  // look stores depth for as long as it does.
17249
- const depthRead = dofOn || this.effects.some((e) => e.hasForeground) || this.subsurfaceInUse()
17476
+ const depthRead = dofOn || this.aovCapture || this.effects.some((e) => e.hasForeground) || this.subsurfaceInUse()
17250
17477
  this.renderPassDescriptor.depthStencilAttachment!.depthStoreOp = depthRead ? "store" : "discard"
17251
17478
  if (depthRead) this.writeDepthOfFieldUniforms()
17252
17479
 
@@ -17268,7 +17495,7 @@ export class Engine {
17268
17495
  if (idAtt) {
17269
17496
  // The flood seeds from the id attachment, so an effect that reads only the
17270
17497
  // DISTANCE still needs the ids kept — it just never names them itself.
17271
- const idsRead = this.idDebug || this.effects.some((e) => e.readsIds || e.readsCastDistance)
17498
+ const idsRead = this.idDebug || this.aovCapture || this.effects.some((e) => e.readsIds || e.readsCastDistance)
17272
17499
  idAtt.storeOp = idsRead ? "store" : "discard"
17273
17500
  }
17274
17501
 
package/src/index.ts CHANGED
@@ -23,6 +23,8 @@ export {
23
23
  RENDERING_LAYER_DEFAULT,
24
24
  RENDERING_LAYER_CHARACTER,
25
25
  type ModelAttachment,
26
+ type SceneAovs,
27
+ type LightProbe,
26
28
  type GizmoDragEvent,
27
29
  type GizmoDragCallback,
28
30
  type GizmoDragKind,
@@ -227,3 +229,5 @@ export type { EyeTrackingOptions } from "./model"
227
229
  export type { NativeStagePackage, NativeStageReader } from "./unity/stage"
228
230
  export type { NativeLook, NativeMaterialSpec, NativeTexture } from "./unity/looks"
229
231
  export type { NativeShader, NativeShaderInfo } from "./unity/host"
232
+ export { AOV_PIXEL_FIELDS, AOV_PIXEL_STRIDE } from "./shaders/passes/aov"
233
+ export { GROUND_MATERIAL_ID, GROUND_OBJECT_ID } from "./shaders/passes/ground"