@viggle/splat-engine-three 0.1.1 → 0.3.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.
Files changed (112) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +158 -20
  3. package/dist/chunks/chunk-2GKWT24B.js +23182 -0
  4. package/dist/chunks/chunk-2GKWT24B.js.map +7 -0
  5. package/dist/index.js +235 -3
  6. package/dist/types/anim/animation-conversion.d.ts +2 -2
  7. package/dist/types/anim/keyframe-splines.d.ts +17 -41
  8. package/dist/types/animation.d.ts +84 -28
  9. package/dist/types/armature.d.ts +280 -2
  10. package/dist/types/character.d.ts +120 -2
  11. package/dist/types/effects/index.d.ts +12 -0
  12. package/dist/types/effects/outlines/outline-effect.d.ts +98 -0
  13. package/dist/types/effects/outlines/outline-shaders.d.ts +14 -0
  14. package/dist/types/effects/pixelart/pixelart-effect.d.ts +152 -0
  15. package/dist/types/effects/pixelart/pixelart-shaders.d.ts +31 -0
  16. package/dist/types/effects/postfx/base-capturing-pass.d.ts +109 -0
  17. package/dist/types/effects/postfx/camera-frame.d.ts +103 -0
  18. package/dist/types/effects/postfx/frame-renderer.d.ts +32 -0
  19. package/dist/types/effects/postfx/frame-shaders.d.ts +19 -0
  20. package/dist/types/effects/postfx/mask.d.ts +44 -0
  21. package/dist/types/effects/postfx/postfx.d.ts +144 -0
  22. package/dist/types/effects/postfx/program.d.ts +74 -0
  23. package/dist/types/effects/postfx/uniforms.d.ts +24 -0
  24. package/dist/types/effects/postfx/webgl-program.d.ts +6 -0
  25. package/dist/types/effects/postfx/webgpu-program.d.ts +3 -0
  26. package/dist/types/effects/vfx/data-types.d.ts +100 -0
  27. package/dist/types/effects/vfx/index.d.ts +37 -0
  28. package/dist/types/effects/vfx/json-vfx-prefab.d.ts +94 -0
  29. package/dist/types/effects/vfx/layer-renderer.d.ts +118 -0
  30. package/dist/types/effects/vfx/layers/mesh.d.ts +124 -0
  31. package/dist/types/effects/vfx/layers/particle.d.ts +90 -0
  32. package/dist/types/effects/vfx/layers/shader.d.ts +130 -0
  33. package/dist/types/effects/vfx/layers/shared.d.ts +40 -0
  34. package/dist/types/effects/vfx/layers/sprite.d.ts +45 -0
  35. package/dist/types/effects/vfx/pool.d.ts +51 -0
  36. package/dist/types/effects/vfx/prefab.d.ts +48 -0
  37. package/dist/types/effects/vfx/prewarm.d.ts +17 -0
  38. package/dist/types/effects/vfx/stage.d.ts +115 -0
  39. package/dist/types/effects/vfx/webgpu-register.d.ts +2 -0
  40. package/dist/types/effects/webgpu-register.d.ts +2 -0
  41. package/dist/types/engine.d.ts +18 -0
  42. package/dist/types/environment.d.ts +96 -8
  43. package/dist/types/index.d.ts +35 -6
  44. package/dist/types/loader/animation/animation-glb.d.ts +4 -4
  45. package/dist/types/loader/character/load.d.ts +6 -1
  46. package/dist/types/loader/environment/lod-bundle.d.ts +123 -0
  47. package/dist/types/loader/environment/spz-decode.d.ts +88 -0
  48. package/dist/types/loader/environment/spz.d.ts +28 -0
  49. package/dist/types/loader/shared/asset-fetch.d.ts +11 -0
  50. package/dist/types/loader/shared/asset-loader.d.ts +86 -0
  51. package/dist/types/loader/shared/bin-cache.d.ts +41 -14
  52. package/dist/types/loader/shared/decode-worker.d.ts +27 -0
  53. package/dist/types/loader/shared/glb.d.ts +30 -0
  54. package/dist/types/loader/shared/inflate.d.ts +9 -0
  55. package/dist/types/loader/shared/pack-splats-task.d.ts +17 -0
  56. package/dist/types/loader/shared/sog-decode.d.ts +81 -0
  57. package/dist/types/loader/shared/sog.d.ts +17 -0
  58. package/dist/types/math.d.ts +198 -13
  59. package/dist/types/physics/ammo.d.ts +217 -0
  60. package/dist/types/physics/index.d.ts +11 -0
  61. package/dist/types/physics/joints.d.ts +206 -0
  62. package/dist/types/physics/physics-world.d.ts +194 -0
  63. package/dist/types/physics/rigid-body.d.ts +361 -0
  64. package/dist/types/presets/camera/camera-preset.d.ts +43 -0
  65. package/dist/types/presets/camera/third-person-camera.d.ts +63 -0
  66. package/dist/types/presets/character/body-shape.d.ts +109 -0
  67. package/dist/types/presets/character/character-reveal.d.ts +90 -0
  68. package/dist/types/presets/character/socket-loadout.d.ts +61 -0
  69. package/dist/types/presets/index.d.ts +13 -0
  70. package/dist/types/presets/vfx/mesh-flash.d.ts +51 -0
  71. package/dist/types/presets/visual/bone-overlay.d.ts +57 -0
  72. package/dist/types/proxy/environment-input.d.ts +30 -0
  73. package/dist/types/proxy/environment-source.d.ts +39 -0
  74. package/dist/types/proxy/proxy-debug.d.ts +106 -0
  75. package/dist/types/proxy/splat-source.d.ts +42 -0
  76. package/dist/types/proxy/voxelizer.d.ts +383 -0
  77. package/dist/types/relight/backend.d.ts +101 -0
  78. package/dist/types/relight/index.d.ts +6 -0
  79. package/dist/types/relight/relight-pass.d.ts +367 -0
  80. package/dist/types/relight/relight-placeholder.d.ts +2 -0
  81. package/dist/types/relight/relight-shaders.d.ts +4 -0
  82. package/dist/types/relight/shadow-bias.d.ts +26 -0
  83. package/dist/types/relight/splat-relight.d.ts +760 -0
  84. package/dist/types/relight/webgl-backend.d.ts +3 -0
  85. package/dist/types/relight/webgpu/backend.d.ts +3 -0
  86. package/dist/types/relight/webgpu-register.d.ts +2 -0
  87. package/dist/types/scene.d.ts +291 -0
  88. package/dist/types/skeletal/animation-player.d.ts +31 -3
  89. package/dist/types/skeletal/body-parts.d.ts +55 -0
  90. package/dist/types/skeletal/ragdoll-config.d.ts +115 -0
  91. package/dist/types/skeletal/ragdoll.d.ts +283 -0
  92. package/dist/types/skeletal/skeleton.d.ts +9 -2
  93. package/dist/types/splat/backend.d.ts +2 -0
  94. package/dist/types/splat/color-modifier.d.ts +78 -0
  95. package/dist/types/splat/cut-groups.d.ts +27 -0
  96. package/dist/types/splat/relight-binding.d.ts +39 -0
  97. package/dist/types/splat/reveal-bake.d.ts +43 -0
  98. package/dist/types/splat/reveal-look.d.ts +64 -0
  99. package/dist/types/splat/splat-mesh.d.ts +1 -0
  100. package/dist/types/splat/splat.d.ts +154 -0
  101. package/dist/types/splat/webgl/shaders.d.ts +5 -1
  102. package/dist/types/splat/webgl/splat-mesh.d.ts +4 -0
  103. package/dist/types/splat/webgpu/radix-sort.d.ts +3 -0
  104. package/dist/types/splat/webgpu/splat-mesh.d.ts +23 -0
  105. package/dist/types/three/splat-character.d.ts +28 -0
  106. package/dist/types/three/spz-loader.d.ts +35 -0
  107. package/dist/types/types.d.ts +6 -0
  108. package/dist/webgpu.js +1137 -154
  109. package/dist/webgpu.js.map +4 -4
  110. package/package.json +6 -2
  111. package/dist/chunks/chunk-WN5WBKM4.js +0 -8606
  112. package/dist/chunks/chunk-WN5WBKM4.js.map +0 -7
package/dist/webgpu.js CHANGED
@@ -1,11 +1,67 @@
1
1
  import {
2
+ ALL_BODY_PARTS,
2
3
  Animation,
3
4
  Armature,
5
+ BODYGROUP_DEFAULT,
6
+ BODYGROUP_DYNAMIC,
7
+ BODYGROUP_ENGINE_1,
8
+ BODYGROUP_ENGINE_2,
9
+ BODYGROUP_ENGINE_3,
10
+ BODYGROUP_KINEMATIC,
11
+ BODYGROUP_NONE,
12
+ BODYGROUP_STATIC,
13
+ BODYGROUP_TRIGGER,
14
+ BODYGROUP_USER_1,
15
+ BODYGROUP_USER_2,
16
+ BODYGROUP_USER_3,
17
+ BODYGROUP_USER_4,
18
+ BODYGROUP_USER_5,
19
+ BODYGROUP_USER_6,
20
+ BODYGROUP_USER_7,
21
+ BODYGROUP_USER_8,
22
+ BODYMASK_ALL,
23
+ BODYMASK_NONE,
24
+ BODYMASK_NOT_STATIC,
25
+ BODYMASK_NOT_STATIC_KINEMATIC,
26
+ BODYMASK_STATIC,
27
+ BODY_PART_SLUGS,
28
+ BaseCapturingPass,
29
+ BodyPart,
30
+ BodyShapeVariant,
31
+ BoneOverlay,
32
+ CameraFrame,
4
33
  Character,
5
34
  CharacterBundleError,
35
+ DEFAULT_ENV_REVEAL_LOOK,
36
+ DEFAULT_HUMANOID_RAGDOLL,
37
+ DEFAULT_REVEAL_LOOK,
38
+ DEFAULT_REVEAL_PRESET,
39
+ DEFAULT_SHADER_FRAGMENT,
40
+ DEFAULT_SHADER_FRAGMENT_WGSL,
41
+ ENVIRONMENT_DEFAULT_LOD,
42
+ ENVIRONMENT_PROXY_DEFAULTS,
6
43
  EngineDisposedError,
7
44
  Environment,
45
+ JsonVfxInstance,
46
+ JsonVfxPrefab,
47
+ LOWER_BODY_BONE_NAMES,
48
+ Mat4,
49
+ MeshFlash,
50
+ MeshLayerRenderer,
51
+ NUM_BODY_PARTS,
52
+ OutlineEffect,
53
+ ParticleLayerRenderer,
54
+ PhysicsWorld,
55
+ PixelartEffect,
8
56
  PointLight,
57
+ Pose,
58
+ PostFX,
59
+ Quat,
60
+ Ragdoll,
61
+ RigidBody,
62
+ Scene,
63
+ SceneDestroyedError,
64
+ ShaderLayerRenderer,
9
65
  SkyLight,
10
66
  Splat,
11
67
  SplatCharacter,
@@ -14,25 +70,514 @@ import {
14
70
  SplatMesh,
15
71
  SplatPLYLoader,
16
72
  SplatQuality,
73
+ SplatRelight,
74
+ SplatSPZLoader,
75
+ SpriteLayerRenderer,
17
76
  SunLight,
77
+ TONEMAP_ACES,
78
+ TONEMAP_ACES2,
79
+ TONEMAP_FILMIC,
80
+ TONEMAP_HEJL,
81
+ TONEMAP_LINEAR,
82
+ TONEMAP_NEUTRAL,
83
+ TONEMAP_NONE,
84
+ ThirdPersonCamera,
85
+ UPPER_BODY_BONE_NAMES,
18
86
  VSplatLoader,
87
+ Vec3,
88
+ VfxLayerRegistry,
89
+ VfxPool,
90
+ VfxStage,
19
91
  WebGLSplatBackend,
92
+ alphaFromLogits,
93
+ assignUniform,
20
94
  beginFrameTimings,
95
+ bodyPartLabel,
96
+ buildBoneToGroup,
97
+ buildProxyMesh,
98
+ buildSourceBoneRemap,
99
+ buildStretch,
100
+ buildVfxQuadMesh,
101
+ buildVfxRingMesh,
102
+ buildVfxSphereMesh,
103
+ buildVfxSpikeMesh,
104
+ buildVoxelGrid,
105
+ cachedFetch,
106
+ classifyBone,
107
+ clearAnimRootRotation,
108
+ computeBoneStretch,
109
+ createConeTwistJoint,
110
+ createGeneric6DofJoint,
111
+ createHingeJoint,
112
+ createPointToPointJoint,
21
113
  decodeCharacterBundle,
114
+ decodeSplatFile,
115
+ decodeSpz,
116
+ defaultLayerRegistry,
117
+ defaultProxySettings,
22
118
  effectiveMinPixelSize,
119
+ evictExpired,
120
+ extractSurface,
121
+ getRelightPlaceholder,
122
+ getVfxMesh,
123
+ indexAssetCache,
124
+ initialUniformValue,
125
+ installFetchInterceptor,
126
+ isCached,
127
+ isSocketRemoval,
23
128
  loadCharacterBundle,
24
129
  loadCharacterBundleFromBytes,
130
+ loadGlbFromUrl,
131
+ loadSplatAsset,
132
+ loadSplatSource,
25
133
  makeRegionMask,
134
+ mergeSocketLoadout,
26
135
  packSplats,
27
136
  parseGaussianPly,
137
+ playReveal,
138
+ prewarmJsonVfxPrefabs,
28
139
  pruneSplats,
29
- registerWebGPUBackend
30
- } from "./chunks/chunk-WN5WBKM4.js";
140
+ registerPostFXWebGPUBackend,
141
+ registerRelightWebGPUBackend,
142
+ registerShaderLayerWebGPU,
143
+ registerWebGPUBackend,
144
+ registerWebGPURendererFactory,
145
+ resolveBoneIndices,
146
+ setAssetFetch,
147
+ setBinFetch,
148
+ setGlbLoader,
149
+ setPlayCanvasLightColor,
150
+ setShareSplatResources,
151
+ uninstallFetchInterceptor,
152
+ validateShaderGLSL
153
+ } from "./chunks/chunk-2GKWT24B.js";
31
154
 
32
- // src/splat/webgpu/lighting.ts
155
+ // src/webgpu.ts
156
+ import { WebGPURenderer } from "three/webgpu";
157
+
158
+ // src/effects/postfx/webgpu-program.ts
33
159
  import * as TSL from "three/tsl";
34
- import { Vector4 } from "three/webgpu";
35
- var { Fn, If, Loop, float, int, length, uniform, uniformArray } = TSL;
160
+ import {
161
+ AddEquation,
162
+ CustomBlending,
163
+ DataTexture,
164
+ LinearSRGBColorSpace,
165
+ NoBlending,
166
+ NoToneMapping,
167
+ NodeMaterial,
168
+ NormalBlending,
169
+ OneFactor,
170
+ QuadMesh,
171
+ Vector2
172
+ } from "three/webgpu";
173
+ var { code, screenCoordinate, texture, sampler, uniform, wgslFn } = TSL;
174
+ var TEXTURE_DECL = /^\s*var\s+(\w+)\s*:\s*texture_2d<f32>\s*;[^\S\n]*(?:\/\/.*)?$/gm;
175
+ var SAMPLER_DECL = /^\s*var\s+(\w+)\s*:\s*sampler\s*;[^\S\n]*(?:\/\/.*)?$/gm;
176
+ var UNIFORM_DECL = /^\s*uniform\s+(\w+)\s*:\s*(\w+)\s*;[^\S\n]*(?:\/\/.*)?$/gm;
177
+ var ENTRY = /(?:@fragment\s+)?fn\s+fragmentMain\s*\(\s*input\s*:\s*FragmentInput\s*\)\s*->\s*FragmentOutput\s*\{/;
178
+ var WGSL_TYPES = {
179
+ f32: "float",
180
+ i32: "int",
181
+ vec2f: "vec2",
182
+ vec3f: "vec3",
183
+ vec4f: "vec4"
184
+ };
185
+ var PARAM_TYPES = {
186
+ float: "f32",
187
+ int: "i32",
188
+ vec2: "vec2f",
189
+ vec3: "vec3f",
190
+ vec4: "vec4f",
191
+ texture: "texture_2d<f32>",
192
+ sampler: "sampler"
193
+ };
194
+ function adaptWGSL(name, source) {
195
+ const uniforms = [];
196
+ let body = source.replace(TEXTURE_DECL, (_m, n) => {
197
+ uniforms.push({ name: n, type: "texture" });
198
+ return "";
199
+ }).replace(SAMPLER_DECL, (_m, n) => {
200
+ uniforms.push({ name: n, type: "sampler" });
201
+ return "";
202
+ }).replace(UNIFORM_DECL, (_m, n, t) => {
203
+ const type = WGSL_TYPES[t];
204
+ if (!type) throw new Error(`[PostFX] ${name}: unsupported WGSL uniform type '${t}' for '${n}'`);
205
+ uniforms.push({ name: n, type });
206
+ return "";
207
+ });
208
+ const entry = ENTRY.exec(body);
209
+ if (!entry) throw new Error(`[PostFX] ${name}: no 'fn fragmentMain(input: FragmentInput) -> FragmentOutput'`);
210
+ const prelude = body.slice(0, entry.index);
211
+ if (/\buniform\./.test(prelude)) {
212
+ throw new Error(`[PostFX] ${name}: uniforms can only be read inside fragmentMain; pass them to helpers as arguments`);
213
+ }
214
+ for (const u of uniforms) {
215
+ if (u.type === "sampler" && !uniforms.some((t) => t.type === "texture" && `${t.name}Sampler` === u.name)) {
216
+ throw new Error(`[PostFX] ${name}: sampler '${u.name}' must be named after its texture, as '<texture>Sampler'`);
217
+ }
218
+ }
219
+ const params = uniforms.map((u) => `${u.name}: ${PARAM_TYPES[u.type]}`);
220
+ body = body.slice(entry.index + entry[0].length).replace(/var\s+output\s*:\s*FragmentOutput\s*;/, "var output: vec4f;").replace(/\boutput\.color\b/g, "output").replace(/\buniform\.(\w+)/g, "$1").replace(/\binput\.position\b/g, "vec4f(fxFragCoord, 0.0, 1.0)").replace(/\binput\.vUv0\b/g, "vec2f(fxFragCoord.x / fxSize.x, 1.0 - fxFragCoord.y / fxSize.y)").replace(/\binput\.texUv\b/g, "(fxFragCoord / fxSize)");
221
+ const main = `fn fxMain(${["fxFragCoord: vec2f", "fxSize: vec2f", ...params].join(", ")}) -> vec4f {${body}`;
222
+ return { main, prelude, uniforms };
223
+ }
224
+ var PLACEHOLDER = new DataTexture(new Uint8Array(4), 1, 1);
225
+ PLACEHOLDER.needsUpdate = true;
226
+ var WebGPUPostFXProgram = class {
227
+ _renderer;
228
+ _material;
229
+ _quad;
230
+ _values = /* @__PURE__ */ new Map();
231
+ _size;
232
+ constructor(renderer, source) {
233
+ this._renderer = renderer;
234
+ const { main, prelude, uniforms } = adaptWGSL(source.name, source.wgsl);
235
+ const includes = prelude.trim() ? [code(prelude)] : [];
236
+ const fn = wgslFn(main, includes);
237
+ this._size = uniform(new Vector2(1, 1));
238
+ const args = { fxFragCoord: screenCoordinate, fxSize: this._size };
239
+ const textures = /* @__PURE__ */ new Map();
240
+ for (const u of uniforms) {
241
+ if (u.type !== "texture") continue;
242
+ const node = texture(PLACEHOLDER);
243
+ textures.set(u.name, node);
244
+ args[u.name] = node;
245
+ this._values.set(u.name, node);
246
+ }
247
+ for (const u of uniforms) {
248
+ if (u.type === "texture") continue;
249
+ if (u.type === "sampler") {
250
+ args[u.name] = sampler(textures.get(u.name.slice(0, -"Sampler".length)));
251
+ continue;
252
+ }
253
+ const node = u.type === "int" ? uniform(0, "int") : uniform(initialUniformValue(u.type));
254
+ args[u.name] = node;
255
+ this._values.set(u.name, node);
256
+ }
257
+ const material = new NodeMaterial();
258
+ material.name = source.name;
259
+ material.fragmentNode = fn(args);
260
+ material.depthTest = false;
261
+ material.depthWrite = false;
262
+ const blend = source.blend ?? "none";
263
+ material.transparent = blend !== "none";
264
+ material.blending = blend === "add" ? CustomBlending : blend === "alpha" ? NormalBlending : NoBlending;
265
+ material.blendEquation = AddEquation;
266
+ material.blendSrc = OneFactor;
267
+ material.blendDst = OneFactor;
268
+ material.blendSrcAlpha = OneFactor;
269
+ material.blendDstAlpha = OneFactor;
270
+ this._material = material;
271
+ this._quad = new QuadMesh(material);
272
+ }
273
+ set(name, value) {
274
+ const holder = this._values.get(name);
275
+ if (!holder) return;
276
+ assignUniform(holder, holder.isTextureNode ? value ?? PLACEHOLDER : value);
277
+ }
278
+ draw(target) {
279
+ const r = this._renderer;
280
+ const autoClear = r.autoClear;
281
+ const colorSpace = r.outputColorSpace;
282
+ const toneMapping = r.toneMapping;
283
+ r.autoClear = false;
284
+ r.setRenderTarget(target);
285
+ if (!target) {
286
+ r.outputColorSpace = LinearSRGBColorSpace;
287
+ r.toneMapping = NoToneMapping;
288
+ }
289
+ if (target) this._size.value.set(target.width, target.height);
290
+ else r.getDrawingBufferSize(this._size.value);
291
+ this._quad.render(r);
292
+ r.outputColorSpace = colorSpace;
293
+ r.toneMapping = toneMapping;
294
+ r.autoClear = autoClear;
295
+ }
296
+ dispose() {
297
+ this._material.dispose();
298
+ }
299
+ };
300
+ var webgpuPostFXBackend = {
301
+ createProgram: (renderer, source) => new WebGPUPostFXProgram(renderer, source)
302
+ };
303
+
304
+ // src/effects/webgpu-register.ts
305
+ function registerEffectsWebGPU() {
306
+ registerPostFXWebGPUBackend(webgpuPostFXBackend);
307
+ }
308
+
309
+ // src/effects/vfx/webgpu-register.ts
310
+ import * as TSL2 from "three/tsl";
311
+ import { NodeMaterial as NodeMaterial2, Vector2 as Vector22, Vector3, Vector4 } from "three/webgpu";
312
+ var {
313
+ asin,
314
+ atan,
315
+ cameraProjectionMatrix,
316
+ cameraViewMatrix,
317
+ clamp,
318
+ cross,
319
+ float,
320
+ length,
321
+ mix,
322
+ modelWorldMatrix,
323
+ normalize,
324
+ normalLocal,
325
+ positionLocal,
326
+ sRGBTransferEOTF,
327
+ uniform: uniform2,
328
+ uv,
329
+ varying,
330
+ vec2,
331
+ vec3,
332
+ vec4,
333
+ wgslFn: wgslFn2
334
+ } = TSL2;
335
+ function uniformFor(value) {
336
+ if (typeof value === "number") return uniform2(value);
337
+ switch (value.length) {
338
+ case 2:
339
+ return uniform2(new Vector22(value[0], value[1]));
340
+ case 3:
341
+ return uniform2(new Vector3(value[0], value[1], value[2]));
342
+ case 4:
343
+ return uniform2(new Vector4(value[0], value[1], value[2], value[3]));
344
+ default:
345
+ throw new Error(`[VFX] shader layer uniforms are float or vec2-4; got ${value.length} values`);
346
+ }
347
+ }
348
+ function assign(node, value) {
349
+ if (typeof value === "number") node.value = value;
350
+ else node.value.fromArray(value);
351
+ }
352
+ function vertexStage(material, geometry) {
353
+ if (geometry === "billboard") {
354
+ const center = modelWorldMatrix.element(3).xyz;
355
+ const sx = length(modelWorldMatrix.element(0).xyz);
356
+ const sy = length(modelWorldMatrix.element(1).xyz);
357
+ const camRight = vec3(cameraViewMatrix.element(0).x, cameraViewMatrix.element(1).x, cameraViewMatrix.element(2).x);
358
+ const camUp = vec3(cameraViewMatrix.element(0).y, cameraViewMatrix.element(1).y, cameraViewMatrix.element(2).y);
359
+ const worldPos = center.add(camRight.mul(positionLocal.x.mul(sx))).add(camUp.mul(positionLocal.y.mul(sy)));
360
+ material.vertexNode = cameraProjectionMatrix.mul(cameraViewMatrix).mul(vec4(worldPos, 1));
361
+ return {
362
+ vUv: varying(uv()),
363
+ vLocalPos: varying(positionLocal),
364
+ vWorldPos: varying(worldPos),
365
+ vNormal: varying(normalize(cross(camRight, camUp)))
366
+ };
367
+ }
368
+ const world = modelWorldMatrix.mul(vec4(positionLocal, 1));
369
+ material.vertexNode = cameraProjectionMatrix.mul(cameraViewMatrix).mul(world);
370
+ const vNormal = varying(normalize(modelWorldMatrix.mul(vec4(normalLocal, 0)).xyz));
371
+ if (geometry === "sphere") {
372
+ const d = normalize(positionLocal);
373
+ return {
374
+ vUv: varying(vec2(
375
+ atan(d.z, d.x).div(6.28318530718).add(0.5),
376
+ asin(clamp(d.y, -1, 1)).div(3.14159265359).add(0.5)
377
+ )),
378
+ vLocalPos: varying(positionLocal),
379
+ vWorldPos: varying(world.xyz),
380
+ vNormal
381
+ };
382
+ }
383
+ return { vUv: varying(uv()), vLocalPos: varying(positionLocal), vWorldPos: varying(world.xyz), vNormal };
384
+ }
385
+ function wgslMaterial(layer, geometry) {
386
+ const material = new NodeMaterial2();
387
+ material.name = `VfxShader_${layer.id}_${geometry}`;
388
+ const uniforms = {
389
+ uTime: uniform2(0),
390
+ uProgress: uniform2(0),
391
+ uDuration: uniform2(layer.duration ?? 0),
392
+ uOpacity: uniform2(layer.opacity ?? 1)
393
+ };
394
+ for (const [name, spec] of Object.entries(layer.uniforms ?? {})) {
395
+ if (spec && spec.value != null) uniforms[name] = uniformFor(spec.value);
396
+ }
397
+ const outputLinear = uniform2(0);
398
+ const source = layer.fragmentWGSL.replace(/\bfn\s+main\s*\(/, "fn vfxShaderMain(");
399
+ const fragment = wgslFn2(source)({ ...vertexStage(material, geometry), ...uniforms });
400
+ const color = vec4(fragment);
401
+ material.fragmentNode = vec4(mix(color.rgb, sRGBTransferEOTF(color.rgb), float(outputLinear)), color.a);
402
+ return {
403
+ material,
404
+ set(name, value) {
405
+ const node = uniforms[name];
406
+ if (node) assign(node, value);
407
+ },
408
+ beforeRender(renderer, _mesh, _camera) {
409
+ const r = renderer;
410
+ const target = r.getRenderTarget();
411
+ const encodedOnOutput = target ? target.isPostProcessingRenderTarget === true : r.needsFrameBufferTarget === true;
412
+ outputLinear.value = encodedOnOutput ? 1 : 0;
413
+ }
414
+ };
415
+ }
416
+ function registerVfxWebGPU() {
417
+ registerShaderLayerWebGPU(wgslMaterial);
418
+ }
419
+
420
+ // src/relight/webgpu/backend.ts
421
+ import * as TSL3 from "three/tsl";
422
+ import {
423
+ HalfFloatType,
424
+ LightingModel,
425
+ LinearFilter,
426
+ MeshLambertNodeMaterial,
427
+ NodeMaterial as NodeMaterial3,
428
+ QuadMesh as QuadMesh2,
429
+ RGBAFormat,
430
+ RenderTarget,
431
+ Vector3 as Vector32,
432
+ Vector4 as Vector42
433
+ } from "three/webgpu";
434
+ var { Fn, dot, float: float2, max, normalView, normalWorld, reference, sqrt, texture: texture2, uniform: uniform3, uv: uv2, vec2: vec22, vec3: vec32, vec4: vec42 } = TSL3;
435
+ var RelightLightingModel = class extends LightingModel {
436
+ direct({ lightDirection, lightColor, lightNode, reflectedLight }, builder) {
437
+ let color = lightColor;
438
+ if (lightNode.light.isPointLight) {
439
+ const range = lightNode.cutoffDistanceNode;
440
+ const d = lightNode.getLightVector(builder).length();
441
+ const falloff = range.greaterThan(0).select(max(range.sub(d).div(range), 0), float2(1));
442
+ color = lightNode.colorNode.mul(falloff);
443
+ }
444
+ const dotNL = normalView.dot(lightDirection).clamp();
445
+ reflectedLight.directDiffuse.addAssign(dotNL.mul(color));
446
+ }
447
+ };
448
+ var RelightProxyMaterial = class extends MeshLambertNodeMaterial {
449
+ /** Marks the receivers the key light's {@link keyLightBias} applies to. */
450
+ isRelightProxyMaterial = true;
451
+ constructor() {
452
+ super();
453
+ this.name = "relight-proxy";
454
+ this.fog = false;
455
+ this.toneMapped = false;
456
+ }
457
+ // No environment light: the proxy's output is direct light only, and the
458
+ // compose adds the ambient back. The scene's environment map stays set
459
+ // while the proxies render, because clearing it rebuilds every material.
460
+ setupEnvironment() {
461
+ return null;
462
+ }
463
+ // Typed as the parent's return, which narrows it to Phong.
464
+ setupLightingModel() {
465
+ return new RelightLightingModel();
466
+ }
467
+ };
468
+ function keyLightBias(light, proxyBias) {
469
+ const toLightNode = uniform3(proxyBias.toLight);
470
+ const slopeNode = uniform3(0).onRenderUpdate(() => proxyBias.slope);
471
+ const shadow = light.shadow;
472
+ const bias = reference("bias", "float", shadow);
473
+ const range = reference("far", "float", shadow.camera).sub(reference("near", "float", shadow.camera));
474
+ return Fn((builder) => {
475
+ if (!builder.material?.isRelightProxyMaterial) return bias;
476
+ const c = max(dot(normalWorld, toLightNode), 1e-3);
477
+ const tan = sqrt(max(float2(1).sub(c.mul(c)), 0)).div(c);
478
+ return dot(normalWorld, toLightNode).greaterThan(0).select(bias.sub(slopeNode.mul(tan).div(range)), bias);
479
+ })();
480
+ }
481
+ var LUMA = [0.2126, 0.7152, 0.0722];
482
+ var WebGPURelightComposer = class {
483
+ _lit = texture2(getRelightPlaceholder());
484
+ _raw = texture2(getRelightPlaceholder());
485
+ _params = uniform3(new Vector42());
486
+ _hasRaw = uniform3(0);
487
+ _ambient = uniform3(new Vector32());
488
+ _lighting = new NodeMaterial3();
489
+ _visibility = new NodeMaterial3();
490
+ _quad = new QuadMesh2(this._lighting);
491
+ constructor() {
492
+ const coord = uv2();
493
+ const params = this._params;
494
+ const tent = (src, radius) => {
495
+ const c = src.sample(coord);
496
+ const t = vec22(params.x, params.y).mul(radius);
497
+ const tap = (x, y) => src.sample(coord.add(t.mul(vec22(x, y))));
498
+ const sum = c.mul(4).add(tap(-1, -1)).add(tap(0, -1).mul(2)).add(tap(1, -1)).add(tap(-1, 0).mul(2)).add(tap(1, 0).mul(2)).add(tap(-1, 1)).add(tap(0, 1).mul(2)).add(tap(1, 1));
499
+ return radius.lessThanEqual(0).select(c, sum.div(16));
500
+ };
501
+ const luma = vec32(...LUMA);
502
+ const lit = tent(this._lit, params.z);
503
+ const cov = lit.a.clamp(0, 1);
504
+ const direct = cov.greaterThan(1e-4).select(lit.rgb.div(cov), vec32(0));
505
+ const raw = tent(this._raw, params.w);
506
+ const rawCov = raw.a.clamp(0, 1);
507
+ const unshadowed = rawCov.greaterThan(1e-4).select(raw.rgb.div(rawCov), vec32(0));
508
+ const total = dot(unshadowed, luma);
509
+ const reaching = dot(direct, luma);
510
+ const visibility = this._hasRaw.greaterThan(0.5).and(total.greaterThan(1e-4)).select(reaching.div(total).clamp(0, 1), float2(1));
511
+ this._lighting.name = "relight-compose-lighting";
512
+ this._lighting.fragmentNode = vec42(direct.add(this._ambient), cov);
513
+ this._visibility.name = "relight-compose-visibility";
514
+ this._visibility.fragmentNode = vec42(visibility, cov, 0, 1);
515
+ for (const material of [this._lighting, this._visibility]) {
516
+ material.depthTest = false;
517
+ material.depthWrite = false;
518
+ material.toneMapped = false;
519
+ material.fog = false;
520
+ }
521
+ }
522
+ render(renderer, lit, raw, lighting, visibility, params) {
523
+ const r = renderer;
524
+ this._lit.value = lit;
525
+ this._raw.value = raw ?? lit;
526
+ this._hasRaw.value = raw ? 1 : 0;
527
+ this._params.value.set(params.texelX, params.texelY, params.blurRadius, params.shadowBlurRadius);
528
+ this._ambient.value.copy(params.ambient);
529
+ this._quad.material = this._lighting;
530
+ r.setRenderTarget(lighting);
531
+ this._quad.render(r);
532
+ this._quad.material = this._visibility;
533
+ r.setRenderTarget(visibility);
534
+ this._quad.render(r);
535
+ }
536
+ dispose() {
537
+ this._lighting.dispose();
538
+ this._visibility.dispose();
539
+ }
540
+ };
541
+ var webgpuRelightBackend = {
542
+ // WebGPU target rows run top-down: NDC +1 lands in row 0, which `v = 0`
543
+ // samples, so the splat lookup's `uv = ndc * 0.5 + 0.5` reads the mirrored
544
+ // row unless it flips.
545
+ flipY: true,
546
+ proxyReadsEnvironment: false,
547
+ // The bias is taken on the key light instead (see keyLightBias).
548
+ createProxyMaterial() {
549
+ return new RelightProxyMaterial();
550
+ },
551
+ configureKeyLight(light, bias) {
552
+ light.shadow.biasNode = keyLightBias(light, bias);
553
+ },
554
+ createTarget(_renderer, width, height, depth) {
555
+ return new RenderTarget(width, height, {
556
+ type: HalfFloatType,
557
+ format: RGBAFormat,
558
+ // Bilinear, not point: an animated splat's screen position drifts across
559
+ // this texture every frame and a point read pops at texel boundaries.
560
+ minFilter: LinearFilter,
561
+ magFilter: LinearFilter,
562
+ generateMipmaps: false,
563
+ depthBuffer: depth,
564
+ stencilBuffer: false
565
+ });
566
+ },
567
+ createComposer() {
568
+ return new WebGPURelightComposer();
569
+ }
570
+ };
571
+
572
+ // src/relight/webgpu-register.ts
573
+ function registerRelightWebGPU() {
574
+ registerRelightWebGPUBackend(webgpuRelightBackend);
575
+ }
576
+
577
+ // src/splat/webgpu/lighting.ts
578
+ import * as TSL4 from "three/tsl";
579
+ import { Vector4 as Vector43 } from "three/webgpu";
580
+ var { Fn: Fn2, If, Loop, float: float3, int, length: length2, uniform: uniform4, uniformArray } = TSL4;
36
581
  var MAX_POINT_LIGHTS = 16;
37
582
  var WebGPULighting = class {
38
583
  _engine;
@@ -47,12 +592,12 @@ var WebGPULighting = class {
47
592
  _version = -1;
48
593
  constructor(engine) {
49
594
  this._engine = engine;
50
- this._sunColor = uniform(engine.lightingUniforms.uSunColor.value);
51
- this._ambient = uniform(engine.lightingUniforms.uAmbientColor.value);
52
- this._sunIntensity = uniform(0);
53
- this._pointCount = uniform(0, "int");
54
- this._pointPosRange = Array.from({ length: MAX_POINT_LIGHTS }, () => new Vector4());
55
- this._pointColor = Array.from({ length: MAX_POINT_LIGHTS }, () => new Vector4());
595
+ this._sunColor = uniform4(engine.lightingUniforms.uSunColor.value);
596
+ this._ambient = uniform4(engine.lightingUniforms.uAmbientColor.value);
597
+ this._sunIntensity = uniform4(0);
598
+ this._pointCount = uniform4(0, "int");
599
+ this._pointPosRange = Array.from({ length: MAX_POINT_LIGHTS }, () => new Vector43());
600
+ this._pointColor = Array.from({ length: MAX_POINT_LIGHTS }, () => new Vector43());
56
601
  this._pointPosRangeNode = uniformArray(this._pointPosRange, "vec4");
57
602
  this._pointColorNode = uniformArray(this._pointColor, "vec4");
58
603
  }
@@ -82,15 +627,15 @@ var WebGPULighting = class {
82
627
  * range-attenuated point lights. With no lights it is exactly 1.
83
628
  */
84
629
  litFactor(worldCenter) {
85
- return Fn(() => {
630
+ return Fn2(() => {
86
631
  const lit = this._ambient.add(this._sunColor.mul(this._sunIntensity)).toVar();
87
632
  Loop({ start: int(0), end: this._pointCount, type: "int", condition: "<" }, ({ i }) => {
88
633
  const posRange = this._pointPosRangeNode.element(i);
89
634
  const colorInt = this._pointColorNode.element(i);
90
- const dist = length(posRange.xyz.sub(worldCenter)).toVar();
635
+ const dist = length2(posRange.xyz.sub(worldCenter)).toVar();
91
636
  If(dist.lessThan(posRange.w), () => {
92
637
  const t = dist.div(posRange.w);
93
- const atten = float(1).sub(t.mul(t)).toVar();
638
+ const atten = float3(1).sub(t.mul(t)).toVar();
94
639
  lit.addAssign(colorInt.xyz.mul(colorInt.w).mul(atten.mul(atten)));
95
640
  });
96
641
  });
@@ -100,27 +645,27 @@ var WebGPULighting = class {
100
645
  };
101
646
 
102
647
  // src/splat/webgpu/splat-mesh.ts
103
- import * as TSL3 from "three/tsl";
648
+ import * as TSL6 from "three/tsl";
104
649
  import {
105
650
  BufferAttribute,
106
651
  DoubleSide,
107
652
  InstancedBufferGeometry,
108
653
  Matrix3,
109
654
  Matrix4,
110
- NodeMaterial,
655
+ NodeMaterial as NodeMaterial4,
111
656
  Quaternion,
112
657
  SRGBColorSpace,
113
658
  Sphere,
114
659
  StorageBufferAttribute as StorageBufferAttribute2,
115
- Vector2,
116
- Vector3,
117
- Vector4 as Vector42
660
+ Vector2 as Vector23,
661
+ Vector3 as Vector33,
662
+ Vector4 as Vector44
118
663
  } from "three/webgpu";
119
664
 
120
665
  // src/splat/webgpu/radix-sort.ts
121
- import * as TSL2 from "three/tsl";
666
+ import * as TSL5 from "three/tsl";
122
667
  import { StorageBufferAttribute } from "three/webgpu";
123
- var { Fn: Fn2, If: If2, Loop: Loop2, atomicAdd, atomicStore, instanceIndex, storage, uint } = TSL2;
668
+ var { Fn: Fn3, If: If2, Loop: Loop2, atomicAdd, atomicStore, instanceIndex, storage, uint } = TSL5;
124
669
  var SORT_KEY_BITS = 16;
125
670
  var RADIX = 256;
126
671
  var BLOCK = 256;
@@ -134,6 +679,8 @@ var GpuRadixSort = class {
134
679
  resetNode;
135
680
  /** Run, in order, after the pass that writes keys. */
136
681
  sortNodes;
682
+ /** Every buffer the sort allocated, for the owner to free with its nodes. */
683
+ attributes;
137
684
  _firstHistogram;
138
685
  constructor(count) {
139
686
  this.count = count;
@@ -147,6 +694,7 @@ var GpuRadixSort = class {
147
694
  const digitAttribute = new StorageBufferAttribute(new Uint32Array(RADIX), 1);
148
695
  const halfSortedAttribute = new StorageBufferAttribute(new Uint32Array(count), 1);
149
696
  const orderAttribute = new StorageBufferAttribute(new Uint32Array(count), 1);
697
+ this.attributes = [keysAttribute, ...histogramAttributes, digitAttribute, halfSortedAttribute, orderAttribute];
150
698
  this.keysWrite = storage(keysAttribute, "uint", count);
151
699
  const keys = storage(keysAttribute, "uint", count).toReadOnly();
152
700
  this.orderRead = storage(orderAttribute, "uint", count).toReadOnly();
@@ -156,13 +704,13 @@ var GpuRadixSort = class {
156
704
  const halfSortedWrite = storage(halfSortedAttribute, "uint", count);
157
705
  const halfSorted = storage(halfSortedAttribute, "uint", count).toReadOnly();
158
706
  const orderWrite = storage(orderAttribute, "uint", count);
159
- this.resetNode = Fn2(() => {
707
+ this.resetNode = Fn3(() => {
160
708
  atomicStore(this._firstHistogram.element(instanceIndex), uint(0));
161
709
  atomicStore(secondHistogramAtomic.element(instanceIndex), uint(0));
162
710
  })().compute(histogramSize, [256]).setName("SplatSortReset");
163
711
  const prefixBlocks = (pass) => {
164
712
  const histogram = storage(histogramAttributes[pass], "uint", histogramSize);
165
- return Fn2(() => {
713
+ return Fn3(() => {
166
714
  const sum = uint(0).toVar();
167
715
  Loop2({ start: 0, end: blocks, type: "uint", name: "b", condition: "<" }, ({ b }) => {
168
716
  const slot = b.mul(RADIX).add(instanceIndex).toVar();
@@ -173,7 +721,7 @@ var GpuRadixSort = class {
173
721
  digits.element(instanceIndex).assign(sum);
174
722
  })().compute(RADIX, [64]).setName(`SplatSortPrefixBlocks${pass}`);
175
723
  };
176
- const prefixDigits = (pass) => Fn2(() => {
724
+ const prefixDigits = (pass) => Fn3(() => {
177
725
  const sum = uint(0).toVar();
178
726
  Loop2({ start: 0, end: RADIX, type: "uint", name: "d", condition: "<" }, ({ d }) => {
179
727
  const n = digits.element(d).toVar();
@@ -184,7 +732,7 @@ var GpuRadixSort = class {
184
732
  const scatter = (pass, input, output) => {
185
733
  const histogram = storage(histogramAttributes[pass], "uint", histogramSize);
186
734
  const digitBases = storage(digitAttribute, "uint", RADIX).toReadOnly();
187
- return Fn2(() => {
735
+ return Fn3(() => {
188
736
  const first = instanceIndex.mul(BLOCK).toVar();
189
737
  Loop2({ start: 0, end: BLOCK, type: "uint", name: "j", condition: "<" }, ({ j }) => {
190
738
  const position = first.add(j).toVar();
@@ -200,7 +748,7 @@ var GpuRadixSort = class {
200
748
  });
201
749
  })().compute(blocks, [64]).setName(`SplatSortScatter${pass}`);
202
750
  };
203
- const secondHistogramNode = Fn2(() => {
751
+ const secondHistogramNode = Fn3(() => {
204
752
  const element = halfSorted.element(instanceIndex).toVar();
205
753
  const digit = keys.element(element).shiftRight(uint(8)).bitAnd(uint(RADIX - 1)).toVar();
206
754
  const block = instanceIndex.div(uint(BLOCK));
@@ -230,48 +778,58 @@ var GpuRadixSort = class {
230
778
  // src/splat/webgpu/splat-mesh.ts
231
779
  var {
232
780
  Discard,
233
- Fn: Fn3,
781
+ Fn: Fn4,
234
782
  If: If3,
235
783
  Loop: Loop3,
236
- clamp,
237
- dot,
784
+ clamp: clamp2,
785
+ cos,
786
+ cross: cross2,
787
+ dot: dot2,
238
788
  exp,
239
- float: float2,
789
+ float: float4,
790
+ fract,
240
791
  instanceIndex: instanceIndex2,
241
- length: length2,
792
+ int: int2,
793
+ ivec2,
794
+ length: length3,
242
795
  log,
243
- max,
796
+ max: max2,
244
797
  min,
245
- mix,
246
- normalize,
798
+ mix: mix2,
799
+ normalize: normalize2,
247
800
  positionGeometry,
248
801
  select,
249
- sqrt,
802
+ sin,
803
+ smoothstep,
804
+ sqrt: sqrt2,
250
805
  storage: storage2,
806
+ texture: texture3,
807
+ textureLoad,
251
808
  uint: uint2,
252
809
  uintBitsToFloat,
253
- uniform: uniform2,
810
+ uniform: uniform5,
254
811
  uniformArray: uniformArray2,
255
812
  unpackHalf2x16,
256
813
  uvec4,
257
814
  varyingProperty,
258
- vec2,
259
- vec3,
260
- vec4
261
- } = TSL3;
815
+ vec2: vec23,
816
+ vec3: vec33,
817
+ vec4: vec43,
818
+ wgslFn: wgslFn3
819
+ } = TSL6;
262
820
  var SORT_BINS = 1 << SORT_KEY_BITS;
263
821
  var WORKGROUP_SIZE = 256;
264
822
  var MAX_VARIANT_GROUPS = 64;
265
823
  var EXP4 = Math.exp(-4);
266
824
  var INV_EXP4 = 1 / (1 - EXP4);
267
- var _position = new Vector3();
825
+ var _position = new Vector33();
268
826
  var _quaternion = new Quaternion();
269
- var _scale = new Vector3();
270
- var _viewport = new Vector42();
827
+ var _scale = new Vector33();
828
+ var _viewport = new Vector44();
271
829
  var _sphere = new Sphere();
272
- var _viewCenter = new Vector3();
273
- var _direction = new Vector3();
274
- var INPUT_SLOTS = 80;
830
+ var _viewCenter = new Vector33();
831
+ var _direction = new Vector33();
832
+ var INPUT_SLOTS = 100;
275
833
  var WebGPUSplatImpl = class {
276
834
  geometry;
277
835
  material;
@@ -290,37 +848,65 @@ var WebGPUSplatImpl = class {
290
848
  _projectNodes = [];
291
849
  /** The sort proper - needed only when the depth ORDER may have changed. */
292
850
  _sortNodes = [];
851
+ /** Storage buffers the current build allocated. */
852
+ _buffers = [];
853
+ /** Nodes and buffers of builds since replaced, freed on the next frame. */
854
+ _retired = [];
855
+ /** The renderer that drew this splat, which owns its GPU buffers. */
856
+ _renderer = null;
293
857
  // What the last compute run saw. Compared field by field each frame so an
294
858
  // unchanged splat costs a draw call and nothing else.
295
859
  _lastInputs = new Float64Array(INPUT_SLOTS).fill(NaN);
296
860
  _inputs = new Float64Array(INPUT_SLOTS);
297
- _lastSortDirection = new Vector3(NaN, NaN, NaN);
861
+ _lastSortDirection = new Vector33(NaN, NaN, NaN);
298
862
  _buildId = 0;
299
863
  _sortedBuildId = -1;
300
864
  _allNodes = null;
865
+ /** Relight texture nodes, re-pointed when the binding's textures change. */
866
+ _relightTex = null;
867
+ _relightShadowTex = null;
868
+ /** Cut texture nodes [offsets, pivots, rotations], re-pointed when a re-cut reallocates them. */
869
+ _cutTex = null;
870
+ /** True when the colour can change with no input this backend can see (a game hook). */
871
+ _alwaysProject = false;
872
+ /** Copies the game hook's uniform values into their nodes. */
873
+ _syncHook = null;
301
874
  // Per-drawable uniforms, refreshed in onBeforeRender.
302
875
  _u = {
303
- model: uniform2(new Matrix4()),
304
- modelLinear: uniform2(new Matrix3()),
305
- modelRotation: uniform2(new Vector42(0, 0, 0, 1)),
306
- modelScale: uniform2(new Vector3(1, 1, 1)),
307
- view: uniform2(new Matrix4()),
308
- viewRow0: uniform2(new Vector3()),
309
- viewRow1: uniform2(new Vector3()),
310
- viewRow2: uniform2(new Vector3()),
311
- projection: uniform2(new Matrix4()),
312
- viewport: uniform2(new Vector2(1, 1)),
313
- minPixelSize: uniform2(0),
876
+ model: uniform5(new Matrix4()),
877
+ modelLinear: uniform5(new Matrix3()),
878
+ modelRotation: uniform5(new Vector44(0, 0, 0, 1)),
879
+ modelScale: uniform5(new Vector33(1, 1, 1)),
880
+ view: uniform5(new Matrix4()),
881
+ viewRow0: uniform5(new Vector33()),
882
+ viewRow1: uniform5(new Vector33()),
883
+ viewRow2: uniform5(new Vector33()),
884
+ projection: uniform5(new Matrix4()),
885
+ viewport: uniform5(new Vector23(1, 1)),
886
+ minPixelSize: uniform5(0),
314
887
  // 1 / the alpha a splat's quad is allowed to end at, carried as the
315
888
  // reciprocal so the historic 1/255 cutoff arrives as exactly 255 and the
316
889
  // two expressions it feeds reduce to what they were before the cutoff was
317
890
  // a setting. See SplatQuality.quadAlphaCutoff.
318
- alphaCutoffScale: uniform2(255),
891
+ alphaCutoffScale: uniform5(255),
319
892
  // x: far depth, y: 1 / (far - near), along the view axis.
320
- sortRange: uniform2(new Vector2(1, 1)),
321
- tint: uniform2(new Vector42(1, 1, 1, 0)),
322
- grade: uniform2(new Vector2(1, 1)),
323
- outputLinear: uniform2(0),
893
+ sortRange: uniform5(new Vector23(1, 1)),
894
+ tint: uniform5(new Vector44(1, 1, 1, 0)),
895
+ grade: uniform5(new Vector23(1, 1)),
896
+ // x opacity, y reveal amount, z reveal inverse, w cut amount.
897
+ effects: uniform5(new Vector44(1, 1, 0, 0)),
898
+ revealBand: uniform5(new Vector44()),
899
+ revealSketch: uniform5(new Vector44()),
900
+ revealTint: uniform5(new Vector44()),
901
+ relightVP: uniform5(new Matrix4()),
902
+ relightParams: uniform5(new Vector44()),
903
+ relightStrength: uniform5(0),
904
+ relightTint: uniform5(new Vector33(1, 1, 1)),
905
+ relightAmbient: uniform5(0),
906
+ relightShadowStrength: uniform5(0),
907
+ relightFlipY: uniform5(0),
908
+ relightDebug: uniform5(0),
909
+ outputLinear: uniform5(0),
324
910
  variantMask: uniformArray2(this._variantMask, "float")
325
911
  };
326
912
  constructor(host, splat, lighting) {
@@ -332,7 +918,7 @@ var WebGPUSplatImpl = class {
332
918
  geometry.setIndex([0, 1, 2, 0, 2, 3]);
333
919
  geometry.instanceCount = splat.numSplats;
334
920
  geometry.boundingSphere = new Sphere();
335
- const material = new NodeMaterial();
921
+ const material = new NodeMaterial4();
336
922
  material.name = "SplatMaterial";
337
923
  material.transparent = true;
338
924
  material.depthTest = true;
@@ -371,6 +957,10 @@ var WebGPUSplatImpl = class {
371
957
  attribute.needsUpdate = true;
372
958
  this.requestSort();
373
959
  }
960
+ /** The relight textures are re-pointed every frame; a new binding only needs a rebuild when one turns on or off. */
961
+ syncRelight() {
962
+ this.requestSort();
963
+ }
374
964
  syncVariantGroups() {
375
965
  const attribute = this._groupAttribute;
376
966
  const ids = this._splat.groupIds;
@@ -385,6 +975,15 @@ var WebGPUSplatImpl = class {
385
975
  * palette outgrows its buffer.
386
976
  */
387
977
  _build() {
978
+ if (this._projectNodes.length > 0) {
979
+ this._retired.push({ nodes: [...this._projectNodes, ...this._sortNodes], buffers: this._buffers });
980
+ }
981
+ const buffers = [];
982
+ this._buffers = buffers;
983
+ const track = (attribute) => {
984
+ buffers.push(attribute);
985
+ return attribute;
986
+ };
388
987
  const splat = this._splat;
389
988
  const count = splat.numSplats;
390
989
  const packed = splat.packed;
@@ -406,15 +1005,15 @@ var WebGPUSplatImpl = class {
406
1005
  splatData[o + 6] = srcC[i * 2];
407
1006
  splatData[o + 7] = srcC[i * 2 + 1];
408
1007
  }
409
- const splats = storage2(new StorageBufferAttribute2(splatData, 4), "uvec4", count * 2).toReadOnly();
1008
+ const splats = storage2(track(new StorageBufferAttribute2(splatData, 4)), "uvec4", count * 2).toReadOnly();
410
1009
  this._paletteArray = splat.transformPalette.data;
411
- this._paletteAttribute = new StorageBufferAttribute2(this._paletteArray, 4);
1010
+ this._paletteAttribute = track(new StorageBufferAttribute2(this._paletteArray, 4));
412
1011
  this._paletteVersion = -1;
413
1012
  const palette = storage2(this._paletteAttribute, "vec4", this._paletteArray.length / 4).toReadOnly();
414
1013
  let bones = null;
415
1014
  this._boneAttribute = null;
416
1015
  if (skinned) {
417
- this._boneAttribute = new StorageBufferAttribute2(packBoneInfluences(splat, new Uint32Array(count * 4)), 4);
1016
+ this._boneAttribute = track(new StorageBufferAttribute2(packBoneInfluences(splat, new Uint32Array(count * 4)), 4));
418
1017
  bones = storage2(this._boneAttribute, "uvec4", count).toReadOnly();
419
1018
  }
420
1019
  let groupIds = null;
@@ -425,60 +1024,95 @@ var WebGPUSplatImpl = class {
425
1024
  `WebGPUSplatBackend: ${splat.variantMask.length} variant groups requested, but this backend supports at most ${MAX_VARIANT_GROUPS}`
426
1025
  );
427
1026
  }
428
- this._groupAttribute = new StorageBufferAttribute2(Uint32Array.from(splat.groupIds), 1);
1027
+ this._groupAttribute = track(new StorageBufferAttribute2(Uint32Array.from(splat.groupIds), 1));
429
1028
  groupIds = storage2(this._groupAttribute, "uint", count).toReadOnly();
430
1029
  }
431
- const workAttribute = new StorageBufferAttribute2(new Float32Array(count * 12), 4);
1030
+ const workAttribute = track(new StorageBufferAttribute2(new Float32Array(count * 12), 4));
432
1031
  const workWrite = storage2(workAttribute, "vec4", count * 3);
433
1032
  const sort = new GpuRadixSort(count);
1033
+ buffers.push(...sort.attributes);
434
1034
  const readPaletteRows = (slot) => {
435
1035
  const base = slot.mul(3).toVar();
436
1036
  const r0 = palette.element(base).toVar();
437
1037
  const r1 = palette.element(base.add(1)).toVar();
438
1038
  const r2 = palette.element(base.add(2)).toVar();
439
- const empty = max(
440
- length2(vec3(r0.x, r1.x, r2.x)),
441
- max(length2(vec3(r0.y, r1.y, r2.y)), length2(vec3(r0.z, r1.z, r2.z)))
1039
+ const empty = max2(
1040
+ length3(vec33(r0.x, r1.x, r2.x)),
1041
+ max2(length3(vec33(r0.y, r1.y, r2.y)), length3(vec33(r0.z, r1.z, r2.z)))
442
1042
  ).lessThanEqual(1e-4);
443
1043
  return [
444
- select(empty, vec4(1, 0, 0, 0), r0),
445
- select(empty, vec4(0, 1, 0, 0), r1),
446
- select(empty, vec4(0, 0, 1, 0), r2)
1044
+ select(empty, vec43(1, 0, 0, 0), r0),
1045
+ select(empty, vec43(0, 1, 0, 0), r1),
1046
+ select(empty, vec43(0, 0, 1, 0), r2)
447
1047
  ];
448
1048
  };
449
- const quatMul = (a, b) => vec4(
1049
+ const quatMul = (a, b) => vec43(
450
1050
  a.w.mul(b.x).add(a.x.mul(b.w)).add(a.y.mul(b.z)).sub(a.z.mul(b.y)),
451
1051
  a.w.mul(b.y).sub(a.x.mul(b.z)).add(a.y.mul(b.w)).add(a.z.mul(b.x)),
452
1052
  a.w.mul(b.z).add(a.x.mul(b.y)).sub(a.y.mul(b.x)).add(a.z.mul(b.w)),
453
1053
  a.w.mul(b.w).sub(a.x.mul(b.x)).sub(a.y.mul(b.y)).sub(a.z.mul(b.z))
454
1054
  );
455
- const sRGBToLinear = (c) => mix(
456
- c.mul(0.9478672986).add(0.0521327014).pow(vec3(2.4)),
1055
+ const sRGBToLinear = (c) => mix2(
1056
+ c.mul(0.9478672986).add(0.0521327014).pow(vec33(2.4)),
457
1057
  c.mul(0.0773993808),
458
- c.lessThanEqual(vec3(0.04045))
1058
+ c.lessThanEqual(vec33(0.04045))
459
1059
  );
460
- const projectNode = Fn3(() => {
1060
+ const texWidth = packed.width;
1061
+ const splatTexel = (i) => ivec2(int2(i.mod(texWidth)), int2(i.div(texWidth)));
1062
+ const revealOn = splat.revealEnabled;
1063
+ const revealDistance = revealOn && skinned && splat.revealDistanceTexture ? texture3(splat.revealDistanceTexture) : null;
1064
+ const cutOn = splat.cutEnabled && !!groupIds && !!splat.groupOffsetsTexture;
1065
+ const cutOffsets = cutOn ? texture3(splat.groupOffsetsTexture) : null;
1066
+ const cutPivots = cutOn ? texture3(splat.groupPivotsTexture) : null;
1067
+ const cutRots = cutOn ? texture3(splat.groupRotsTexture) : null;
1068
+ this._cutTex = cutOn ? [cutOffsets, cutPivots, cutRots] : null;
1069
+ const relight = splat.relightBinding;
1070
+ this._relightTex = relight ? texture3(relight.texture) : null;
1071
+ this._relightShadowTex = relight ? texture3(relight.shadowTexture ?? relight.texture) : null;
1072
+ const relightTex = this._relightTex;
1073
+ const relightShadowTex = this._relightShadowTex;
1074
+ const hook = splat.colorModifier;
1075
+ const builtHook = hook ? buildColorHook(hook) : null;
1076
+ const hookFn = builtHook?.fn ?? null;
1077
+ this._syncHook = builtHook?.sync ?? null;
1078
+ this._alwaysProject = !!hookFn;
1079
+ const revealX = (i, reveal) => {
1080
+ const front = mix2(u.revealBand.x.negate(), u.revealBand.x.add(1), reveal);
1081
+ const d = revealDistance ? textureLoad(revealDistance, splatTexel(i)).x : float4(1);
1082
+ return front.sub(d);
1083
+ };
1084
+ const revealHot = (base) => {
1085
+ const LUMA2 = vec33(0.2126, 0.7152, 0.0722);
1086
+ const tint = u.revealTint.xyz;
1087
+ const floorLuma = max2(u.revealTint.w, 1e-4);
1088
+ const luma = dot2(base, LUMA2).toVar();
1089
+ const hot = clamp2(mix2(vec33(luma), base, 2.2).mul(1.9), 0, 1).toVar();
1090
+ hot.assign(clamp2(mix2(hot, tint.mul(max2(luma, 0.35)).mul(2), 0.3), 0, 1));
1091
+ const lift = clamp2(floorLuma.sub(dot2(hot, LUMA2)).div(floorLuma), 0, 1);
1092
+ return mix2(hot, tint, lift);
1093
+ };
1094
+ const projectNode = Fn4(() => {
461
1095
  const tA = splats.element(instanceIndex2.mul(2)).toVar();
462
1096
  const tB = splats.element(instanceIndex2.mul(2).add(1)).toVar();
463
1097
  const modelCenter = uintBitsToFloat(tA.xyz).toVar();
464
1098
  const rotXY = unpackHalf2x16(tA.w).toVar();
465
1099
  const scaleXY = unpackHalf2x16(tB.x).toVar();
466
1100
  const scaleZRotZ = unpackHalf2x16(tB.y).toVar();
467
- const packedRot = vec3(rotXY.x, rotXY.y, scaleZRotZ.y).toVar();
468
- const srcRotation = vec4(packedRot, sqrt(max(float2(0), float2(1).sub(dot(packedRot, packedRot))))).toVar();
469
- const srcScale = vec3(scaleXY.x, scaleXY.y, scaleZRotZ.x).toVar();
470
- const row0 = vec4(1, 0, 0, 0).toVar();
471
- const row1 = vec4(0, 1, 0, 0).toVar();
472
- const row2 = vec4(0, 0, 1, 0).toVar();
1101
+ const packedRot = vec33(rotXY.x, rotXY.y, scaleZRotZ.y).toVar();
1102
+ const srcRotation = vec43(packedRot, sqrt2(max2(float4(0), float4(1).sub(dot2(packedRot, packedRot))))).toVar();
1103
+ const srcScale = vec33(scaleXY.x, scaleXY.y, scaleZRotZ.x).toVar();
1104
+ const row0 = vec43(1, 0, 0, 0).toVar();
1105
+ const row1 = vec43(0, 1, 0, 0).toVar();
1106
+ const row2 = vec43(0, 0, 1, 0).toVar();
473
1107
  if (skinned) {
474
1108
  const influences = bones.element(instanceIndex2).toVar();
475
1109
  const idx = influences.bitAnd(uvec4(65535)).toVar();
476
- const weights = vec4(influences.shiftRight(uvec4(16))).div(65535).toVar();
1110
+ const weights = vec43(influences.shiftRight(uvec4(16))).div(65535).toVar();
477
1111
  const total = weights.x.add(weights.y).add(weights.z).add(weights.w).toVar();
478
1112
  If3(total.greaterThan(1e-3), () => {
479
- const b0 = vec4(0).toVar();
480
- const b1 = vec4(0).toVar();
481
- const b2 = vec4(0).toVar();
1113
+ const b0 = vec43(0).toVar();
1114
+ const b1 = vec43(0).toVar();
1115
+ const b2 = vec43(0).toVar();
482
1116
  for (const k of ["x", "y", "z", "w"]) {
483
1117
  If3(weights[k].greaterThan(1e-3), () => {
484
1118
  const [p0, p1, p2] = readPaletteRows(idx[k]);
@@ -487,13 +1121,13 @@ var WebGPUSplatImpl = class {
487
1121
  b2.addAssign(p2.mul(weights[k]));
488
1122
  });
489
1123
  }
490
- const inv = float2(1).div(total);
1124
+ const inv = float4(1).div(total);
491
1125
  b0.mulAssign(inv);
492
1126
  b1.mulAssign(inv);
493
1127
  b2.mulAssign(inv);
494
- const reasonable = max(
495
- length2(vec3(b0.x, b1.x, b2.x)),
496
- max(length2(vec3(b0.y, b1.y, b2.y)), length2(vec3(b0.z, b1.z, b2.z)))
1128
+ const reasonable = max2(
1129
+ length3(vec33(b0.x, b1.x, b2.x)),
1130
+ max2(length3(vec33(b0.y, b1.y, b2.y)), length3(vec33(b0.z, b1.z, b2.z)))
497
1131
  ).greaterThan(1e-4);
498
1132
  If3(reasonable, () => {
499
1133
  row0.assign(b0);
@@ -502,39 +1136,54 @@ var WebGPUSplatImpl = class {
502
1136
  });
503
1137
  });
504
1138
  }
505
- const center4 = vec4(modelCenter, 1).toVar();
506
- const modelDeformed = vec3(dot(row0, center4), dot(row1, center4), dot(row2, center4)).toVar();
507
- const worldCenter = u.model.mul(vec4(modelDeformed, 1)).xyz.toVar();
1139
+ const center4 = vec43(modelCenter, 1).toVar();
1140
+ const modelDeformed = vec33(dot2(row0, center4), dot2(row1, center4), dot2(row2, center4)).toVar();
1141
+ const sortCenter = cutOn ? modelDeformed.toVar() : null;
1142
+ if (cutOn) {
1143
+ const amount = u.effects.w;
1144
+ const gid = ivec2(int2(groupIds.element(instanceIndex2)), int2(0)).toVar();
1145
+ const offS = textureLoad(cutOffsets, gid).toVar();
1146
+ const pivot = textureLoad(cutPivots, gid).xyz.toVar();
1147
+ const rot = textureLoad(cutRots, gid).toVar();
1148
+ const angle = rot.w.mul(amount).toVar();
1149
+ const v = modelDeformed.sub(pivot).toVar();
1150
+ const c2 = cos(angle), sn = sin(angle);
1151
+ const turned = v.mul(c2).add(cross2(rot.xyz, v).mul(sn)).add(rot.xyz.mul(dot2(rot.xyz, v)).mul(float4(1).sub(c2)));
1152
+ modelDeformed.assign(pivot.add(turned.mul(mix2(float4(1), offS.w, amount))).add(offS.xyz.mul(amount)));
1153
+ const half = angle.mul(0.5);
1154
+ srcRotation.assign(quatMul(vec43(rot.xyz.mul(sin(half)), cos(half)), srcRotation));
1155
+ }
1156
+ const worldCenter = u.model.mul(vec43(modelDeformed, 1)).xyz.toVar();
508
1157
  const worldRotation = quatMul(u.modelRotation, srcRotation).toVar();
509
1158
  If3(worldRotation.w.lessThan(0), () => {
510
1159
  worldRotation.assign(worldRotation.negate());
511
1160
  });
512
1161
  const worldScale = u.modelScale.mul(srcScale).toVar();
513
1162
  if (skinned) {
514
- const c0 = u.modelLinear.mul(vec3(row0.x, row1.x, row2.x)).toVar();
515
- const c1 = u.modelLinear.mul(vec3(row0.y, row1.y, row2.y)).toVar();
516
- const c2 = u.modelLinear.mul(vec3(row0.z, row1.z, row2.z)).toVar();
517
- const s = vec3(length2(c0), length2(c1), length2(c2)).toVar();
1163
+ const c0 = u.modelLinear.mul(vec33(row0.x, row1.x, row2.x)).toVar();
1164
+ const c1 = u.modelLinear.mul(vec33(row0.y, row1.y, row2.y)).toVar();
1165
+ const c2 = u.modelLinear.mul(vec33(row0.z, row1.z, row2.z)).toVar();
1166
+ const s = vec33(length3(c0), length3(c1), length3(c2)).toVar();
518
1167
  If3(s.x.greaterThan(1e-5).and(s.y.greaterThan(1e-5)).and(s.z.greaterThan(1e-5)), () => {
519
1168
  const x = c0.div(s.x).toVar();
520
1169
  const y = c1.div(s.y).toVar();
521
1170
  const z = c2.div(s.z).toVar();
522
- const q = vec4(0, 0, 0, 1).toVar();
1171
+ const q = vec43(0, 0, 0, 1).toVar();
523
1172
  const trace = x.x.add(y.y).add(z.z).toVar();
524
1173
  If3(trace.greaterThan(0), () => {
525
- const k = sqrt(trace.add(1)).mul(2).toVar();
526
- q.assign(vec4(y.z.sub(z.y).div(k), z.x.sub(x.z).div(k), x.y.sub(y.x).div(k), k.mul(0.25)));
1174
+ const k = sqrt2(trace.add(1)).mul(2).toVar();
1175
+ q.assign(vec43(y.z.sub(z.y).div(k), z.x.sub(x.z).div(k), x.y.sub(y.x).div(k), k.mul(0.25)));
527
1176
  }).ElseIf(x.x.greaterThan(y.y).and(x.x.greaterThan(z.z)), () => {
528
- const k = sqrt(float2(1).add(x.x).sub(y.y).sub(z.z)).mul(2).toVar();
529
- q.assign(vec4(k.mul(0.25), y.x.add(x.y).div(k), z.x.add(x.z).div(k), y.z.sub(z.y).div(k)));
1177
+ const k = sqrt2(float4(1).add(x.x).sub(y.y).sub(z.z)).mul(2).toVar();
1178
+ q.assign(vec43(k.mul(0.25), y.x.add(x.y).div(k), z.x.add(x.z).div(k), y.z.sub(z.y).div(k)));
530
1179
  }).ElseIf(y.y.greaterThan(z.z), () => {
531
- const k = sqrt(float2(1).add(y.y).sub(x.x).sub(z.z)).mul(2).toVar();
532
- q.assign(vec4(y.x.add(x.y).div(k), k.mul(0.25), z.y.add(y.z).div(k), z.x.sub(x.z).div(k)));
1180
+ const k = sqrt2(float4(1).add(y.y).sub(x.x).sub(z.z)).mul(2).toVar();
1181
+ q.assign(vec43(y.x.add(x.y).div(k), k.mul(0.25), z.y.add(y.z).div(k), z.x.sub(x.z).div(k)));
533
1182
  }).Else(() => {
534
- const k = sqrt(float2(1).add(z.z).sub(x.x).sub(y.y)).mul(2).toVar();
535
- q.assign(vec4(z.x.add(x.z).div(k), z.y.add(y.z).div(k), k.mul(0.25), x.y.sub(y.x).div(k)));
1183
+ const k = sqrt2(float4(1).add(z.z).sub(x.x).sub(y.y)).mul(2).toVar();
1184
+ q.assign(vec43(z.x.add(x.z).div(k), z.y.add(y.z).div(k), k.mul(0.25), x.y.sub(y.x).div(k)));
536
1185
  });
537
- const composed = normalize(quatMul(q, srcRotation)).toVar();
1186
+ const composed = normalize2(quatMul(q, srcRotation)).toVar();
538
1187
  If3(composed.w.lessThan(0), () => {
539
1188
  composed.assign(composed.negate());
540
1189
  });
@@ -544,68 +1193,131 @@ var WebGPUSplatImpl = class {
544
1193
  worldScale.mulAssign(s);
545
1194
  }
546
1195
  }
1196
+ if (revealOn) {
1197
+ const reveal = u.effects.y;
1198
+ const inverse = u.effects.z.greaterThan(0.5);
1199
+ const x = revealX(instanceIndex2, reveal).toVar();
1200
+ const inBand = x.greaterThanEqual(0).and(x.lessThan(u.revealBand.x));
1201
+ const m = min(worldScale.x, min(worldScale.y, worldScale.z));
1202
+ const squashed = min(worldScale, vec33(m.mul(u.revealBand.z)));
1203
+ If3(inverse, () => {
1204
+ If3(inBand, () => {
1205
+ worldScale.assign(squashed);
1206
+ });
1207
+ }).ElseIf(reveal.lessThan(1), () => {
1208
+ If3(x.lessThan(0), () => {
1209
+ worldScale.mulAssign(u.revealSketch.z);
1210
+ }).ElseIf(inBand, () => {
1211
+ worldScale.assign(squashed);
1212
+ });
1213
+ });
1214
+ }
547
1215
  const ortho = u.projection.element(3).w.equal(1);
548
- const centerView = u.view.mul(vec4(worldCenter, 1)).toVar();
1216
+ const centerView = u.view.mul(vec43(worldCenter, 1)).toVar();
549
1217
  const centerProj = u.projection.mul(centerView).toVar();
550
- centerProj.z.assign(clamp(centerProj.z, float2(0), centerProj.w.abs()));
1218
+ centerProj.z.assign(clamp2(centerProj.z, float4(0), centerProj.w.abs()));
551
1219
  const qx = worldRotation.x, qy = worldRotation.y, qz = worldRotation.z, qw = worldRotation.w;
552
- const m0 = vec3(
553
- float2(1).sub(qy.mul(qy).add(qz.mul(qz)).mul(2)),
1220
+ const m0 = vec33(
1221
+ float4(1).sub(qy.mul(qy).add(qz.mul(qz)).mul(2)),
554
1222
  qx.mul(qy).add(qw.mul(qz)).mul(2),
555
1223
  qx.mul(qz).sub(qw.mul(qy)).mul(2)
556
1224
  ).mul(worldScale.x).toVar();
557
- const m1 = vec3(
1225
+ const m1 = vec33(
558
1226
  qx.mul(qy).sub(qw.mul(qz)).mul(2),
559
- float2(1).sub(qx.mul(qx).add(qz.mul(qz)).mul(2)),
1227
+ float4(1).sub(qx.mul(qx).add(qz.mul(qz)).mul(2)),
560
1228
  qy.mul(qz).add(qw.mul(qx)).mul(2)
561
1229
  ).mul(worldScale.y).toVar();
562
- const m2 = vec3(
1230
+ const m2 = vec33(
563
1231
  qx.mul(qz).add(qw.mul(qy)).mul(2),
564
1232
  qy.mul(qz).sub(qw.mul(qx)).mul(2),
565
- float2(1).sub(qx.mul(qx).add(qy.mul(qy)).mul(2))
1233
+ float4(1).sub(qx.mul(qx).add(qy.mul(qy)).mul(2))
566
1234
  ).mul(worldScale.z).toVar();
567
1235
  const focal = u.viewport.x.mul(u.projection.element(0).x).toVar();
568
- const vp = select(ortho, vec3(0, 0, 1), centerView.xyz).toVar();
1236
+ const vp = select(ortho, vec33(0, 0, 1), centerView.xyz).toVar();
569
1237
  const J1 = focal.div(vp.z).toVar();
570
1238
  const J2 = vp.xy.mul(J1.negate().div(vp.z)).toVar();
571
1239
  const t0 = u.viewRow0.mul(J1).add(u.viewRow2.mul(J2.x)).toVar();
572
1240
  const t1 = u.viewRow1.mul(J1).add(u.viewRow2.mul(J2.y)).toVar();
573
- const a = vec3(dot(t0, m0), dot(t0, m1), dot(t0, m2)).toVar();
574
- const b = vec3(dot(t1, m0), dot(t1, m1), dot(t1, m2)).toVar();
575
- const cov00 = dot(a, a).toVar();
576
- const cov01 = dot(a, b).toVar();
577
- const cov11 = dot(b, b).toVar();
1241
+ const a = vec33(dot2(t0, m0), dot2(t0, m1), dot2(t0, m2)).toVar();
1242
+ const b = vec33(dot2(t1, m0), dot2(t1, m1), dot2(t1, m2)).toVar();
1243
+ const cov00 = dot2(a, a).toVar();
1244
+ const cov01 = dot2(a, b).toVar();
1245
+ const cov11 = dot2(b, b).toVar();
578
1246
  const diagonal1 = cov00.add(0.3).toVar();
579
1247
  const diagonal2 = cov11.add(0.3).toVar();
580
1248
  const mid = diagonal1.add(diagonal2).mul(0.5).toVar();
581
- const radius = length2(vec2(diagonal1.sub(diagonal2).mul(0.5), cov01)).toVar();
1249
+ const radius = length3(vec23(diagonal1.sub(diagonal2).mul(0.5), cov01)).toVar();
582
1250
  const lambda1 = mid.add(radius).toVar();
583
- const lambda2 = max(mid.sub(radius), 0.1).toVar();
584
- const vmin = min(float2(1024), min(u.viewport.x, u.viewport.y)).toVar();
585
- const l1 = min(sqrt(lambda1.mul(2)), vmin).mul(2).toVar();
586
- const l2 = min(sqrt(lambda2.mul(2)), vmin).mul(2).toVar();
587
- const lmax = max(l1, l2).toVar();
588
- const c = vec2(centerProj.w).div(u.viewport).toVar();
589
- const diagonalVector = normalize(vec2(cov01, lambda1.sub(diagonal1))).toVar();
1251
+ const lambda2 = max2(mid.sub(radius), 0.1).toVar();
1252
+ const vmin = min(float4(1024), min(u.viewport.x, u.viewport.y)).toVar();
1253
+ const l1 = min(sqrt2(lambda1.mul(2)), vmin).mul(2).toVar();
1254
+ const l2 = min(sqrt2(lambda2.mul(2)), vmin).mul(2).toVar();
1255
+ const lmax = max2(l1, l2).toVar();
1256
+ const c = vec23(centerProj.w).div(u.viewport).toVar();
1257
+ const diagonalVector = normalize2(vec23(cov01, lambda1.sub(diagonal1))).toVar();
590
1258
  const v1 = diagonalVector.mul(l1).mul(c).toVar();
591
- const v2 = vec2(diagonalVector.y, diagonalVector.x.negate()).mul(l2).mul(c).toVar();
1259
+ const v2 = vec23(diagonalVector.y, diagonalVector.x.negate()).mul(l2).mul(c).toVar();
592
1260
  const colorRG = unpackHalf2x16(tB.z).toVar();
593
1261
  const colorBA = unpackHalf2x16(tB.w).toVar();
594
- const rgb = vec3(colorRG.x, colorRG.y, colorBA.x).toVar();
1262
+ const rgb = vec33(colorRG.x, colorRG.y, colorBA.x).toVar();
595
1263
  const alpha = colorBA.y.toVar();
596
1264
  if (splat.antiAlias) {
597
1265
  const detOrig = cov00.mul(cov11).sub(cov01.mul(cov01));
598
1266
  const detBlur = diagonal1.mul(diagonal2).sub(cov01.mul(cov01));
599
- alpha.mulAssign(sqrt(max(detOrig.div(detBlur), 0)));
1267
+ alpha.mulAssign(sqrt2(max2(detOrig.div(detBlur), 0)));
600
1268
  }
601
1269
  rgb.mulAssign(lighting.litFactor(worldCenter));
602
- rgb.assign(mix(rgb, u.tint.xyz, clamp(u.tint.w, 0, 1)));
1270
+ If3(u.tint.w.greaterThanEqual(0), () => {
1271
+ rgb.assign(mix2(rgb, u.tint.xyz, clamp2(u.tint.w, 0, 1)));
1272
+ }).Else(() => {
1273
+ rgb.assign(mix2(rgb, rgb.mul(u.tint.xyz), min(u.tint.w.negate(), 1)));
1274
+ });
1275
+ if (relightTex) applyRelight(u, relightTex, relightShadowTex, worldCenter, rgb, alpha);
603
1276
  If3(u.grade.x.notEqual(1).or(u.grade.y.notEqual(1)), () => {
604
1277
  const graded = rgb.sub(0.5).mul(u.grade.x).add(0.5).toVar();
605
- const luma = dot(graded, vec3(0.2126, 0.7152, 0.0722));
606
- rgb.assign(clamp(mix(vec3(luma), graded, u.grade.y), 0, 1));
1278
+ const luma = dot2(graded, vec33(0.2126, 0.7152, 0.0722));
1279
+ rgb.assign(clamp2(mix2(vec33(luma), graded, u.grade.y), 0, 1));
607
1280
  });
608
- rgb.assign(max(rgb, vec3(0)));
1281
+ if (revealOn) {
1282
+ const reveal = u.effects.y;
1283
+ const inverse = u.effects.z.greaterThan(0.5);
1284
+ If3(reveal.lessThan(1).or(inverse), () => {
1285
+ const x = revealX(instanceIndex2, reveal).toVar();
1286
+ const bandWidth = u.revealBand.x;
1287
+ const base = clamp2(rgb, 0, 1).toVar();
1288
+ const hot = revealHot(base).toVar();
1289
+ If3(inverse, () => {
1290
+ If3(x.greaterThanEqual(0), () => {
1291
+ const band = float4(1).sub(smoothstep(0, bandWidth, x));
1292
+ rgb.assign(mix2(base, hot, band));
1293
+ alpha.assign(band.mul(0.95));
1294
+ });
1295
+ }).ElseIf(x.greaterThanEqual(0), () => {
1296
+ const band = float4(1).sub(smoothstep(bandWidth.mul(u.revealBand.y), bandWidth, x)).toVar();
1297
+ rgb.assign(mix2(base, hot, band));
1298
+ alpha.assign(max2(alpha, band.mul(0.95)));
1299
+ }).Else(() => {
1300
+ const lead = u.revealSketch.x;
1301
+ const h = fract(sin(dot2(modelCenter, vec33(12.9898, 78.233, 37.719))).mul(43758.5453));
1302
+ const shown = x.greaterThanEqual(lead.negate()).and(h.lessThanEqual(u.revealSketch.y));
1303
+ rgb.assign(hot);
1304
+ alpha.assign(select(shown, smoothstep(lead.negate(), lead.mul(-0.7), x), float4(0)));
1305
+ });
1306
+ });
1307
+ }
1308
+ alpha.mulAssign(u.effects.x);
1309
+ if (hookFn) {
1310
+ const out = hookFn({
1311
+ center: worldCenter,
1312
+ modelCenter: modelDeformed,
1313
+ restCenter: modelCenter,
1314
+ splatIndex: instanceIndex2,
1315
+ color: vec43(rgb, alpha)
1316
+ }).toVar();
1317
+ rgb.assign(out.xyz);
1318
+ alpha.assign(out.w);
1319
+ }
1320
+ rgb.assign(max2(rgb, vec33(0)));
609
1321
  If3(u.outputLinear.greaterThan(0.5), () => {
610
1322
  rgb.assign(sRGBToLinear(rgb));
611
1323
  });
@@ -619,11 +1331,11 @@ var WebGPUSplatImpl = class {
619
1331
  culled.assign(culled.or(hidden));
620
1332
  }
621
1333
  const slot = instanceIndex2.mul(3).toVar();
622
- workWrite.element(slot).assign(select(culled, vec4(0, 0, 2, 1), centerProj));
623
- workWrite.element(slot.add(1)).assign(select(culled, vec4(0), vec4(v1, v2)));
624
- workWrite.element(slot.add(2)).assign(vec4(rgb, select(culled, float2(0), alpha)));
625
- const depth = centerView.z.negate();
626
- const normalized = clamp(u.sortRange.x.sub(depth).mul(u.sortRange.y), 0, 1);
1334
+ workWrite.element(slot).assign(select(culled, vec43(0, 0, 2, 1), centerProj));
1335
+ workWrite.element(slot.add(1)).assign(select(culled, vec43(0), vec43(v1, v2)));
1336
+ workWrite.element(slot.add(2)).assign(vec43(rgb, select(culled, float4(0), alpha)));
1337
+ const depth = (cutOn ? u.view.mul(u.model.mul(vec43(sortCenter, 1))).z : centerView.z).negate();
1338
+ const normalized = clamp2(u.sortRange.x.sub(depth).mul(u.sortRange.y), 0, 1);
627
1339
  const key = uint2(normalized.mul(SORT_BINS - 1)).toVar();
628
1340
  sort.keysWrite.element(instanceIndex2).assign(key);
629
1341
  sort.countFirstDigit(instanceIndex2, key);
@@ -637,20 +1349,20 @@ var WebGPUSplatImpl = class {
637
1349
  const gaussianUV = varyingProperty("vec2", "vGaussianUV");
638
1350
  const gaussianColor = varyingProperty("vec4", "vGaussianColor");
639
1351
  const material = this.material;
640
- material.vertexNode = Fn3(() => {
1352
+ material.vertexNode = Fn4(() => {
641
1353
  const slot = orderRead.element(instanceIndex2).mul(3).toVar();
642
1354
  const centerProj = workRead.element(slot).toVar();
643
1355
  const axes = workRead.element(slot.add(1)).toVar();
644
1356
  const shade = workRead.element(slot.add(2)).toVar();
645
- const clip = min(float2(1), sqrt(log(max(shade.w.mul(u.alphaCutoffScale), 1))).mul(0.5)).toVar();
1357
+ const clip = min(float4(1), sqrt2(log(max2(shade.w.mul(u.alphaCutoffScale), 1))).mul(0.5)).toVar();
646
1358
  const corner = positionGeometry.xy.toVar();
647
1359
  const offset = axes.xy.mul(corner.x).add(axes.zw.mul(corner.y)).mul(clip);
648
1360
  gaussianUV.assign(corner.mul(clip));
649
1361
  gaussianColor.assign(shade);
650
- return centerProj.add(vec4(offset, 0, 0));
1362
+ return centerProj.add(vec43(offset, 0, 0));
651
1363
  })();
652
- material.colorNode = Fn3(() => {
653
- const A = dot(gaussianUV, gaussianUV).toVar();
1364
+ material.colorNode = Fn4(() => {
1365
+ const A = dot2(gaussianUV, gaussianUV).toVar();
654
1366
  If3(A.greaterThan(1), () => {
655
1367
  Discard();
656
1368
  });
@@ -658,7 +1370,7 @@ var WebGPUSplatImpl = class {
658
1370
  If3(alpha.lessThan(1 / 255), () => {
659
1371
  Discard();
660
1372
  });
661
- return vec4(gaussianColor.xyz, alpha);
1373
+ return vec43(gaussianColor.xyz, alpha);
662
1374
  })();
663
1375
  material.needsUpdate = true;
664
1376
  }
@@ -677,6 +1389,8 @@ var WebGPUSplatImpl = class {
677
1389
  }
678
1390
  /** Refresh this splat's uniforms and run whatever compute this frame needs. */
679
1391
  _prepare(renderer, camera) {
1392
+ this._renderer = renderer;
1393
+ if (this._retired.length > 0) this._freeRetired();
680
1394
  const splat = this._splat;
681
1395
  const u = this._u;
682
1396
  const palette = splat.transformPalette;
@@ -717,6 +1431,31 @@ var WebGPUSplatImpl = class {
717
1431
  }
718
1432
  u.tint.value.copy(splat.tint);
719
1433
  u.grade.value.copy(splat.grade);
1434
+ u.effects.value.copy(splat.effects);
1435
+ u.revealBand.value.copy(splat.revealBand);
1436
+ u.revealSketch.value.copy(splat.revealSketch);
1437
+ u.revealTint.value.copy(splat.revealTint);
1438
+ this._syncHook?.();
1439
+ const cut = this._cutTex;
1440
+ if (cut) {
1441
+ if (cut[0].value !== splat.groupOffsetsTexture) cut[0].value = splat.groupOffsetsTexture;
1442
+ if (cut[1].value !== splat.groupPivotsTexture) cut[1].value = splat.groupPivotsTexture;
1443
+ if (cut[2].value !== splat.groupRotsTexture) cut[2].value = splat.groupRotsTexture;
1444
+ }
1445
+ const relight = splat.relightBinding;
1446
+ if (relight) {
1447
+ u.relightVP.value.copy(relight.viewProjection);
1448
+ u.relightParams.value.copy(relight.params);
1449
+ u.relightStrength.value = relight.strength;
1450
+ u.relightTint.value.copy(relight.tint);
1451
+ u.relightAmbient.value = relight.ambient;
1452
+ u.relightShadowStrength.value = relight.shadowStrength;
1453
+ u.relightFlipY.value = relight.flipY;
1454
+ u.relightDebug.value = relight.debug;
1455
+ if (this._relightTex && relight.texture && this._relightTex.value !== relight.texture) this._relightTex.value = relight.texture;
1456
+ const shadow = relight.shadowTexture ?? relight.texture;
1457
+ if (this._relightShadowTex && shadow && this._relightShadowTex.value !== shadow) this._relightShadowTex.value = shadow;
1458
+ }
720
1459
  const mask = splat.variantMask;
721
1460
  if (mask) for (let i = 0; i < mask.length; i++) this._variantMask[i] = mask[i];
722
1461
  _sphere.copy(this.geometry.boundingSphere).applyMatrix4(world);
@@ -751,6 +1490,13 @@ var WebGPUSplatImpl = class {
751
1490
  inputs[n++] = palette.version;
752
1491
  inputs[n++] = this._buildId;
753
1492
  inputs[n++] = splat.variantMaskVersion;
1493
+ for (const v of [splat.effects, splat.revealBand, splat.revealSketch, splat.revealTint]) {
1494
+ inputs[n++] = v.x;
1495
+ inputs[n++] = v.y;
1496
+ inputs[n++] = v.z;
1497
+ inputs[n++] = v.w;
1498
+ }
1499
+ inputs[n++] = relight ? relight.version : -1;
754
1500
  const last = this._lastInputs;
755
1501
  let changed = false;
756
1502
  for (let i = 0; i < n; i++) {
@@ -759,7 +1505,7 @@ var WebGPUSplatImpl = class {
759
1505
  break;
760
1506
  }
761
1507
  }
762
- if (!changed) return;
1508
+ if (!changed && !this._alwaysProject && !relight) return;
763
1509
  last.set(inputs);
764
1510
  const me = world.elements;
765
1511
  const fx = -ve[2], fy = -ve[6], fz = -ve[10];
@@ -780,7 +1526,24 @@ var WebGPUSplatImpl = class {
780
1526
  dispose() {
781
1527
  this.geometry.dispose();
782
1528
  this.material.dispose();
783
- for (const node of [...this._projectNodes, ...this._sortNodes]) node.dispose?.();
1529
+ this._retired.push({ nodes: [...this._projectNodes, ...this._sortNodes], buffers: this._buffers });
1530
+ this._projectNodes = [];
1531
+ this._sortNodes = [];
1532
+ this._buffers = [];
1533
+ this._freeRetired();
1534
+ }
1535
+ /**
1536
+ * Dispose replaced compute nodes and free their storage buffers. three.js
1537
+ * frees a compute node's pipeline and bindings on dispose, but not the
1538
+ * buffers they read; those it only frees with a geometry they belong to.
1539
+ */
1540
+ _freeRetired() {
1541
+ const attributes = this._renderer?._attributes;
1542
+ for (const { nodes, buffers } of this._retired) {
1543
+ for (const node of nodes) node.dispose?.();
1544
+ if (attributes) for (const buffer of buffers) attributes.delete(buffer);
1545
+ }
1546
+ this._retired.length = 0;
784
1547
  }
785
1548
  };
786
1549
  function packBoneInfluences(splat, out) {
@@ -793,6 +1556,91 @@ function packBoneInfluences(splat, out) {
793
1556
  }
794
1557
  return out;
795
1558
  }
1559
+ function applyRelight(u, tex, shadowTex, worldCenter, rgb, alpha) {
1560
+ const strength = clamp2(u.relightStrength, 0, 1).toVar();
1561
+ const shadowStrength = clamp2(u.relightShadowStrength, 0, 1).toVar();
1562
+ const debug = u.relightDebug.greaterThan(0.5);
1563
+ const debugVis = u.relightDebug.greaterThan(1.5);
1564
+ const clipPos = u.relightVP.mul(vec43(worldCenter, 1)).toVar();
1565
+ const uv3 = clipPos.xy.div(clipPos.w).mul(0.5).add(0.5).toVar();
1566
+ If3(u.relightFlipY.greaterThan(0.5), () => {
1567
+ uv3.y.assign(float4(1).sub(uv3.y));
1568
+ });
1569
+ const active = debug.or(strength.greaterThan(0)).or(shadowStrength.greaterThan(0));
1570
+ const valid = u.relightParams.w.greaterThan(0);
1571
+ const inFront = clipPos.w.greaterThan(0);
1572
+ const inside = uv3.x.greaterThanEqual(0).and(uv3.x.lessThanEqual(1)).and(uv3.y.greaterThanEqual(0)).and(uv3.y.lessThanEqual(1));
1573
+ If3(active, () => {
1574
+ If3(valid.not(), () => {
1575
+ If3(debug, () => {
1576
+ rgb.assign(vec33(1, 0, 1));
1577
+ alpha.assign(1);
1578
+ });
1579
+ }).ElseIf(inFront.not(), () => {
1580
+ If3(debug, () => {
1581
+ rgb.assign(vec33(1, 1, 0));
1582
+ alpha.assign(1);
1583
+ });
1584
+ }).ElseIf(inside.not(), () => {
1585
+ If3(debug, () => {
1586
+ rgb.assign(vec33(1, 0, 0));
1587
+ alpha.assign(1);
1588
+ });
1589
+ }).ElseIf(debugVis, () => {
1590
+ const dv = shadowTex.sample(uv3).level(0).xy.toVar();
1591
+ rgb.assign(select(dv.y.greaterThan(0), vec33(clamp2(dv.x, 0, 1)), vec33(1, 0, 1)));
1592
+ alpha.assign(1);
1593
+ }).ElseIf(debug, () => {
1594
+ const sm = tex.sample(uv3).level(0).toVar();
1595
+ const mirrored = tex.sample(vec23(uv3.x, float4(1).sub(uv3.y))).level(0).w;
1596
+ rgb.assign(select(sm.w.greaterThan(0), sm.xyz, select(mirrored.greaterThan(0), vec33(1, 0.5, 0), vec33(0, 0, 1))));
1597
+ alpha.assign(1);
1598
+ }).Else(() => {
1599
+ If3(strength.greaterThan(0), () => {
1600
+ const sm = tex.sample(uv3).level(0).toVar();
1601
+ const mask = clamp2(sm.w, 0, 1);
1602
+ const lit = max2(sm.xyz.mul(u.relightParams.z), vec33(u.relightAmbient)).mul(u.relightTint);
1603
+ rgb.assign(mix2(rgb, rgb.mul(lit), strength.mul(mask)));
1604
+ });
1605
+ If3(shadowStrength.greaterThan(0), () => {
1606
+ const v = shadowTex.sample(uv3).level(0).xy.toVar();
1607
+ rgb.mulAssign(mix2(float4(1), clamp2(v.x, 0, 1), shadowStrength.mul(clamp2(v.y, 0, 1))));
1608
+ });
1609
+ });
1610
+ });
1611
+ }
1612
+ function buildColorHook(hook) {
1613
+ const uniforms = {};
1614
+ const sources = Object.entries(hook.uniforms ?? {});
1615
+ for (const [name, u] of sources) uniforms[name] = uniform5(u.value);
1616
+ const sync = () => {
1617
+ for (const [name, u] of sources) {
1618
+ const node = uniforms[name];
1619
+ const v = u.value;
1620
+ if (typeof v === "object" && v !== null && typeof node.value?.copy === "function") node.value.copy(v);
1621
+ else node.value = v;
1622
+ }
1623
+ };
1624
+ if (hook.tsl) {
1625
+ const build = hook.tsl;
1626
+ return {
1627
+ sync,
1628
+ fn: (inputs) => build({
1629
+ center: inputs.center,
1630
+ modelCenter: inputs.modelCenter,
1631
+ restCenter: inputs.restCenter,
1632
+ splatIndex: inputs.splatIndex,
1633
+ color: inputs.color,
1634
+ uniforms
1635
+ })
1636
+ };
1637
+ }
1638
+ if (hook.wgsl) {
1639
+ const fn = wgslFn3(hook.wgsl);
1640
+ return { sync, fn: (inputs) => fn({ ...inputs, ...uniforms }) };
1641
+ }
1642
+ return { sync, fn: null };
1643
+ }
796
1644
 
797
1645
  // src/splat/webgpu/backend.ts
798
1646
  var WebGPUSplatBackend = class {
@@ -809,16 +1657,91 @@ var WebGPUSplatBackend = class {
809
1657
 
810
1658
  // src/webgpu.ts
811
1659
  registerWebGPUBackend(new WebGPUSplatBackend());
1660
+ registerEffectsWebGPU();
1661
+ registerVfxWebGPU();
1662
+ registerRelightWebGPU();
1663
+ registerWebGPURendererFactory(async (canvas, opts) => {
1664
+ const gpu = navigator.gpu;
1665
+ if (!gpu) return null;
1666
+ const renderer = new WebGPURenderer({
1667
+ canvas,
1668
+ antialias: opts.antialias ?? false,
1669
+ alpha: (opts.bgColor?.a ?? 1) < 1 || !!opts.preserveDrawingBuffer,
1670
+ powerPreference: opts.powerPreference === "low-power" ? "low-power" : "high-performance"
1671
+ });
1672
+ await renderer.init();
1673
+ if (renderer.backend.isWebGPUBackend !== true) {
1674
+ renderer.dispose();
1675
+ return null;
1676
+ }
1677
+ return renderer;
1678
+ });
812
1679
  export {
1680
+ ALL_BODY_PARTS,
813
1681
  Animation,
814
1682
  Armature,
1683
+ BODYGROUP_DEFAULT,
1684
+ BODYGROUP_DYNAMIC,
1685
+ BODYGROUP_ENGINE_1,
1686
+ BODYGROUP_ENGINE_2,
1687
+ BODYGROUP_ENGINE_3,
1688
+ BODYGROUP_KINEMATIC,
1689
+ BODYGROUP_NONE,
1690
+ BODYGROUP_STATIC,
1691
+ BODYGROUP_TRIGGER,
1692
+ BODYGROUP_USER_1,
1693
+ BODYGROUP_USER_2,
1694
+ BODYGROUP_USER_3,
1695
+ BODYGROUP_USER_4,
1696
+ BODYGROUP_USER_5,
1697
+ BODYGROUP_USER_6,
1698
+ BODYGROUP_USER_7,
1699
+ BODYGROUP_USER_8,
1700
+ BODYMASK_ALL,
1701
+ BODYMASK_NONE,
1702
+ BODYMASK_NOT_STATIC,
1703
+ BODYMASK_NOT_STATIC_KINEMATIC,
1704
+ BODYMASK_STATIC,
1705
+ BODY_PART_SLUGS,
1706
+ BaseCapturingPass,
1707
+ BodyPart,
1708
+ BodyShapeVariant,
1709
+ BoneOverlay,
1710
+ CameraFrame,
815
1711
  Character,
816
1712
  CharacterBundleError,
1713
+ DEFAULT_ENV_REVEAL_LOOK,
1714
+ DEFAULT_HUMANOID_RAGDOLL,
1715
+ DEFAULT_REVEAL_LOOK,
1716
+ DEFAULT_REVEAL_PRESET,
1717
+ DEFAULT_SHADER_FRAGMENT,
1718
+ DEFAULT_SHADER_FRAGMENT_WGSL,
1719
+ ENVIRONMENT_DEFAULT_LOD,
1720
+ ENVIRONMENT_PROXY_DEFAULTS,
817
1721
  EngineDisposedError,
818
1722
  Environment,
1723
+ JsonVfxInstance,
1724
+ JsonVfxPrefab,
1725
+ LOWER_BODY_BONE_NAMES,
819
1726
  MAX_POINT_LIGHTS,
820
1727
  MAX_VARIANT_GROUPS,
1728
+ Mat4,
1729
+ MeshFlash,
1730
+ MeshLayerRenderer,
1731
+ NUM_BODY_PARTS,
1732
+ OutlineEffect,
1733
+ ParticleLayerRenderer,
1734
+ PhysicsWorld,
1735
+ PixelartEffect,
821
1736
  PointLight,
1737
+ Pose,
1738
+ PostFX,
1739
+ Quat,
1740
+ Ragdoll,
1741
+ RigidBody,
1742
+ Scene,
1743
+ SceneDestroyedError,
1744
+ ShaderLayerRenderer,
822
1745
  SkyLight,
823
1746
  Splat,
824
1747
  SplatCharacter,
@@ -828,16 +1751,76 @@ export {
828
1751
  SplatMesh,
829
1752
  SplatPLYLoader,
830
1753
  SplatQuality,
1754
+ SplatRelight,
1755
+ SplatSPZLoader,
1756
+ SpriteLayerRenderer,
831
1757
  SunLight,
1758
+ TONEMAP_ACES,
1759
+ TONEMAP_ACES2,
1760
+ TONEMAP_FILMIC,
1761
+ TONEMAP_HEJL,
1762
+ TONEMAP_LINEAR,
1763
+ TONEMAP_NEUTRAL,
1764
+ TONEMAP_NONE,
1765
+ ThirdPersonCamera,
1766
+ UPPER_BODY_BONE_NAMES,
832
1767
  VSplatLoader,
1768
+ Vec3,
1769
+ VfxLayerRegistry,
1770
+ VfxPool,
1771
+ VfxStage,
833
1772
  WebGLSplatBackend,
834
1773
  WebGPUSplatBackend,
1774
+ alphaFromLogits,
1775
+ bodyPartLabel,
1776
+ buildBoneToGroup,
1777
+ buildProxyMesh,
1778
+ buildSourceBoneRemap,
1779
+ buildStretch,
1780
+ buildVfxQuadMesh,
1781
+ buildVfxRingMesh,
1782
+ buildVfxSphereMesh,
1783
+ buildVfxSpikeMesh,
1784
+ buildVoxelGrid,
1785
+ cachedFetch,
1786
+ classifyBone,
1787
+ clearAnimRootRotation,
1788
+ computeBoneStretch,
1789
+ createConeTwistJoint,
1790
+ createGeneric6DofJoint,
1791
+ createHingeJoint,
1792
+ createPointToPointJoint,
835
1793
  decodeCharacterBundle,
1794
+ decodeSplatFile,
1795
+ decodeSpz,
1796
+ defaultLayerRegistry,
1797
+ defaultProxySettings,
1798
+ evictExpired,
1799
+ extractSurface,
1800
+ getVfxMesh,
1801
+ indexAssetCache,
1802
+ installFetchInterceptor,
1803
+ isCached,
1804
+ isSocketRemoval,
836
1805
  loadCharacterBundle,
837
1806
  loadCharacterBundleFromBytes,
1807
+ loadGlbFromUrl,
1808
+ loadSplatAsset,
1809
+ loadSplatSource,
838
1810
  makeRegionMask,
1811
+ mergeSocketLoadout,
839
1812
  packSplats,
840
1813
  parseGaussianPly,
841
- pruneSplats
1814
+ playReveal,
1815
+ prewarmJsonVfxPrefabs,
1816
+ pruneSplats,
1817
+ resolveBoneIndices,
1818
+ setAssetFetch,
1819
+ setBinFetch,
1820
+ setGlbLoader,
1821
+ setPlayCanvasLightColor,
1822
+ setShareSplatResources,
1823
+ uninstallFetchInterceptor,
1824
+ validateShaderGLSL
842
1825
  };
843
1826
  //# sourceMappingURL=webgpu.js.map