Skip to content

Conversation

@azrogers
Copy link
Contributor

Closes #1219. This PR adds support for the new KHR_gaussian_splatting extension and the KHR_gaussian_splatting_compression_spz_2 extension. The latter is the majority of this PR - it implements SPZ decoding using the spz library, allowing glTFs with SPZ payloads to be read. It also implements backwards compatibility for the KHR_spz_gaussian_splats_compression and KHR_gaussian_splatting_compression_spz extensions, previous iterations that have already had some tilesets created using them.

@azrogers
Copy link
Contributor Author

One random thing to note, might be a concern might not, the SPZ decoding rewrites the color channel to always be a float. This is because I was having some issues with handling conversions to the unsigned byte and unsigned short types that are also allowed, and I figured it wasn't too important to keep the exact data type. But if, for some reason, it is important - I can try to get it working.

@azrogers
Copy link
Contributor Author

Some things I'd like to fix with the spz port (which is done here as an overlay port because there is no official spz port yet):

  • Find a way to put it into a subdirectory, so the includes can be #include <spz/load-spz.h> instead of #include <load-spz.h>
  • Get it to use zstd instead of zlib so we can avoid adding another dependency. This caused issues with the Unreal build for some reason last time I tried it.

"scripts": {
"generate-3d-tiles": "node index.js --schemas https://raw.githubusercontent.com/CesiumGS/3d-tiles/cesium-native/specification/schema/tileset.schema.json https://raw.githubusercontent.com/CesiumGS/3d-tiles/cesium-native/specification/schema/common/rootProperty.schema.json https://raw.githubusercontent.com/CesiumGS/3d-tiles/cesium-native/specification/schema/PropertyTable/propertyTable.schema.json https://raw.githubusercontent.com/CesiumGS/3d-tiles/cesium-native/specification/schema/Subtree/subtree.schema.json https://raw.githubusercontent.com/CesiumGS/3d-tiles/cesium-native/specification/schema/Schema/schema.schema.json https://raw.githubusercontent.com/CesiumGS/3d-tiles/cesium-native/specification/schema/Statistics/statistics.schema.json --output ../../Cesium3DTiles --readerOutput ../../Cesium3DTilesReader --writerOutput ../../Cesium3DTilesWriter --extensions https://raw.githubusercontent.com/CesiumGS/3d-tiles/cesium-native/extensions/ --namespace Cesium3DTiles --readerNamespace Cesium3DTilesReader --writerNamespace Cesium3DTilesWriter --config 3dTiles.json",
"generate-gltf": "node index.js --schemas https://raw.githubusercontent.com/CesiumGS/glTF/cesium-native/specification/2.0/schema/glTF.schema.json --output ../../CesiumGltf --readerOutput ../../CesiumGltfReader --writerOutput ../../CesiumGltfWriter --extensions https://raw.githubusercontent.com/CesiumGS/glTF/cesium-native/extensions/2.0/ --namespace CesiumGltf --readerNamespace CesiumGltfReader --writerNamespace CesiumGltfWriter --config glTF.json",
"generate-gltf": "node index.js --schemas https://raw.githubusercontent.com/CesiumGS/glTF/cesium-native/specification/2.0/schema/glTF.schema.json --output ../../CesiumGltf --readerOutput ../../CesiumGltfReader --writerOutput ../../CesiumGltfWriter --extensions https://raw.githubusercontent.com/CesiumGS/glTF/cesium-native/extensions/2.0/ https://raw.githubusercontent.com/CesiumGS/glTF/draft-splat-spz/extensions/2.0/ --namespace CesiumGltf --readerNamespace CesiumGltfReader --writerNamespace CesiumGltfWriter --config glTF.json",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please open a PR to merge the draft extension into the cesium-native branch, rather than pulling it from a separate branch. Or maybe Adam already did?
CesiumGS/glTF#88

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it needs an update, but you can open another similar PR.

kring added 2 commits October 23, 2025 20:47
It now matches the official vcpkg one as of `2025.09.17`, plus it adds
the `loadSpz.patch` patch to add an overload of loadSpz taking a raw
pointer.
return unpackGaussians(loadSpzPacked(data), o);
}

+GaussianCloud loadSpz(const uint8_t *data, int32_t size, const UnpackOptions &o) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's open a PR upstream for this. It seems like a nice change that should be easy to get accepted, and then we (eventually) won't need an overlay port. spz is in vcpkg now, btw.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Implement KHR_spz_compression

2 participants