Skip to content

feat(SPLAT): Replace manual SPZ loader with NianticLabs WASM implementation and enable 4-th order spherical harmonics#18267

Open
raymondyfei wants to merge 9 commits intoBabylonJS:masterfrom
raymondyfei:yfei/spz_wasm_loader
Open

feat(SPLAT): Replace manual SPZ loader with NianticLabs WASM implementation and enable 4-th order spherical harmonics#18267
raymondyfei wants to merge 9 commits intoBabylonJS:masterfrom
raymondyfei:yfei/spz_wasm_loader

Conversation

@raymondyfei
Copy link
Copy Markdown
Contributor

@raymondyfei raymondyfei commented Apr 9, 2026

This PR replaces the existing manual TypeScript implementation of the SPZ (Splat Zip) loader with NianticLab's official SPZ implementation compiled to WASM (see NianticLabs SPZ for more details). The package was shipped to NPMJS as @adobe/spz because Adobe is responsible for NPM package publication. The primary goal is to improve the consistency and maintainability of loading Gaussian Splatting files within Babylon.js, making it future-proof.

In particular, this PR enables the support of the latest features, such as loading the SPZs with SH4, and vendor-specific extensions.

In addition, we enable the rendering of 4th-order spherical harmonics as it's a shipped feature in the latest version of SPZ.

Changes:

  • Adds @adobe/spz as a dependency in the loaders package, and calls spz.loadSpzFromBuffer() to directly load the SPZ through the WASM library.
  • Removes the manual GZip decompression stream and the custom bit-reading logic previously used to parse the SPZ format.
  • Adds support for the safe-orbit-camera extension loaded from an SPZ file.
  • Adds support for 4th-order spherical harmonics rendering in both WebGL and WebGPU shaders, where we added two optional textures for holding the data.

@sebavan sebavan requested a review from CedricGuillemet April 9, 2026 22:20
@Popov72
Copy link
Copy Markdown
Contributor

Popov72 commented Apr 10, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 10, 2026

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 10, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 10, 2026

Snapshot stored with reference name:
refs/pull/18267/merge

Test environment:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18267/merge/index.html

To test a playground add it to the URL, for example:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18267/merge/index.html#WGZLGJ#4600

Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves):

https://playground.babylonjs.com/?snapshot=refs/pull/18267/merge
https://sandbox.babylonjs.com/?snapshot=refs/pull/18267/merge
https://gui.babylonjs.com/?snapshot=refs/pull/18267/merge
https://nme.babylonjs.com/?snapshot=refs/pull/18267/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/18267/merge#BCU1XR#0

If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 10, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 10, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 10, 2026

@ryantrem
Copy link
Copy Markdown
Member

For the browser, it looks like the wasm is embedded in the js (not a separate .wasm file), so I guess there should be no separate download of a .wasm file or any .wasm hosting or csp or anything like that, which seems good.
For babylon native, we currently have no WebAssembly support, so I think making this change would mean losing support for splat/spz in native. :/

@raymondyfei
Copy link
Copy Markdown
Contributor Author

I think making this change would mean losing support for splat/spz in native

Does Babylon Native use V8 or JavaScriptCore? I thought these two supported WebAssembly. Or is there anything we could do to add support?

@raymondyfei raymondyfei changed the title feat(SPLAT): Replace manual SPZ loader with NianticLabs WASM implementation feat(SPLAT): Replace manual SPZ loader with NianticLabs WASM implementation and enable 4-th order spherical harmonics Apr 10, 2026
@sebavan
Copy link
Copy Markdown
Member

sebavan commented Apr 10, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 10, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 10, 2026

@ryantrem
Copy link
Copy Markdown
Member

I think making this change would mean losing support for splat/spz in native

Does Babylon Native use V8 or JavaScriptCore? I thought these two supported WebAssembly. Or is there anything we could do to add support?

BN works with V8, JavaScriptCore, Chakra, Hermes (via JSI), and there is some experimental work with QuickJS as well. I believe full wasm support is a bit split across V8/JSC and the host browser, and I also believe wasm is restricted on iOS unless it is in the browser (Safari). @bghgary thoughts?

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 10, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 10, 2026

@bghgary
Copy link
Copy Markdown
Contributor

bghgary commented Apr 10, 2026

We tested WebAssembly support on some JS engines, but I don't know the status off the top of my head. Either way, we have not tested WebAssembly much in Babylon Native so more investigation is required regardless. Maybe we could use the native version directly in Babylon Native? We have similar questions for Draco and KTX support.

@raymondyfei
Copy link
Copy Markdown
Contributor Author

I also believe wasm is restricted on iOS unless it is in the browser

We've tested this for iOS 18 (Safari), and the SPZ module works. I'm not sure about other WASM features, though.

@raymondyfei
Copy link
Copy Markdown
Contributor Author

raymondyfei commented Apr 10, 2026

We tested WebAssembly support on some JS engines, but I don't know the status off the top of my head.

I did some searching, and as of 2024, 99% of tracked browsers support WebAssembly 1.0 Wikipedia, and 2024 saw the last major holdout — Safari — add Tail Calls and Garbage Collection, completing cross-browser coverage. Uno Platform Note that Safari on iOS has supported Wasm since iOS 11, not iOS 15 (iOS 15 added improvements, not initial support). Even the extended 2.0 features already exceed 90% browser coverage. Wikipedia

Maybe we could use the native version directly in Babylon Native?

Perhaps this makes both proposed mitigations compelling: a native fallback for the shrinking pool of unsupported platforms, or, simpler still, feature-flagging WASM-dependent capabilities in Babylon Native when running on unsupported kernels?

@Popov72
Copy link
Copy Markdown
Contributor

Popov72 commented Apr 11, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 11, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 11, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 11, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 11, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants