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