-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Gaussian splat spherical harmonics support #12790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Thank you for the pull request, @keyboardspecialist! ✅ We can confirm we have a CLA on file for you. |
What is the SH degree of that example asset? In any case, I think that proper SH support can hardly be implemented (and certainly not tested properly) based on the current SPZ loader, because it does not properly decode the SH data - unless the CesiumJS code is anticipating that wrong encoding, and compensating manually, in which case we just have to hope that it will never be fixed in the SPZ loader. |
The underlying SPZ wasm module decodes it. The raw decoded SH buffer is all we need. Example is degree 3 |
Asked for clarification at drumath2237/spz-loader#36 (comment) There is an effect that is clearly visible: Differences to BabylonJS may be due to coordinate system differences (it's difficult) Test data: |
Babylon makes their lives simpler by rotating the world around the model. The model's inverse rotation matrix is applied to the view angle which should give us the correct sampling. One thing to keep in mind is we do apply a axis correction matrix which may contribute to what you are seeing. When I load our tiled SPZ into Babylon its sideways. That 90 degree rotation might be what you are seeing? |
I think that the different coordinate system conventions can likely explain some differences. Until now, I didn't dive into the maths behind the spherical harmonics. Yes, it's a bunch of coefficients that are mushed together with the view direction and eventually yield a "color". But I don't thoroughly understand the 'meaning of the values'. For example, I'd really like to create such a unit cube with spherical harmonics that looks
This could help to see whether the SHs are taken into account correctly, and whether there are any orientation issues. (If someone knows, from the tip of the head, what the SH values would have to be for that, I'd create an example - until then, this is scheduled in the 'When I have way too much time on my hands'-section of my TODO list). |
Creating predefined test data for this is a bit tricky, though. Deriving the right values from the shader code is close to impossible - there's a reason why there is some magic "iterative learner" blackbox generating these coefficients in "real" applications. I considered a lazy/sneaky approach, and just created a GLB of such a (solid) cube, recorded a video of that spinning it in all directions, and uploaded that to poly.cam, but ... that simply refuses to generate splats from that. (Even if it worked, it might not even possible to derive the right values from that). A bit of trial and error gave the "red-cyan" effect, but only that, and only along the diagonal... ... so I think that it might be possible, and maybe even "easy" for someone who knows what he's doing. Not me, at least, not at the moment. |
Hi @keyboardspecialist, what's the status here? Any input on the testing data discussion above? |
@@ -23,6 +23,7 @@ | |||
- Expand the CustomShader Sample to support real-time modification of CustomShader. [#12702](https://github.com/CesiumGS/cesium/pull/12702) | |||
- Add wrapR property to Sampler and Texture3D, to support the newly added third dimension wrap.[#12701](https://github.com/CesiumGS/cesium/pull/12701) | |||
- Added the ability to load a specific changeset for iTwin Mesh Exports using `ITwinData.createTilesetFromIModelId` [#12778](https://github.com/CesiumGS/cesium/issues/12778) | |||
- Added spherical harmonics support for Gaussian Splats. Supports degrees 1, 2, and 3 in the SPZ format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where can we find a spec or description of the SPZ format? Is the format stable?
A link to the spec, perhaps in GltfVertexBufferLoader
, could go a long way to shortening the spin-up time for future maintainers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing that is closest to a spec is the README of https://github.com/nianticlabs/spz . The actual truth is in the code. Request for clarification are in nianticlabs/spz#42 . This does not yet cover the details of SHs and their layout, but maybe what's in the README is enough... (?)
@jjhembd Here is a small ply data where the correctness of higher-order SH rendering can be clearly perceived. It would be great if it could help. Below is a comparison screenshot from Supersplat. ![]() ![]() |
I guess that it's hard to just "come up" with the proper SH coefficients for that. So I ported the GLSL code from the GaussianSplattingViewer to Java, took the view- and projection matrix and the camera positions for the top/bottom/left/right/front/back view configuration as the inputs, the desired color as the outputs, and interpreted the whole thing as an optimization problem that I fed into the Apache BOBYQAOptimizer. The result as ASCII PLY, SPZ, GLB, and a matching tileset JSON and Sandcastle: Splat SH orientation experiment 2025-08-13.zip This is what it looks like:
(This is rendered with the viewer from JSplat. BabylonJS shows the same for SPZ. For PLY, there seems to be an orientation issue, or I'm writing the coefficients in the wrong order... who knows what's "right" or "wrong" here...) I tried to check the different views in CesiumJS: Looks about right. The bottom is missing - let's just assume it's magenta. |
Description
Adds spherical harmonic support for Gaussian splats in the SPZ format. Supports degrees 1-3 and auto detects what is available. This brings full SPZ support to CesiumJS.
Issue number and link
Testing plan
View the same asset tiled with 3 degrees of SH in the current main build versus the CI brand build:
No SH Support
SH Support
Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change