C++ 构建需要 libz 和 libzstd,缺失时 CMake 会自动通过 FetchContent 下载;构建 TypeScript/WASM 版本前必须先配置 Emscripten SDK;保存和加载时若不指定坐标系(UNSPECIFIED)则不做转换,可能影响互操作性
spz
nianticlabsMIT活跃维护Niantic 开源的 3D 高斯泼溅压缩文件格式,体积比 PLY 小约 10 倍,视觉质量几乎无损,适合存储和分发大规模 3DGS 场景。
File format for 3D Gaussian splats. About 10x smaller than the PLY equivalent with virtually no perceptible loss in visual quality. Offered as open source by Niantic Labs. More details at https://scaniverse.com/spz #3dgaussiansplats #gaussiansplatting
git clone https://github.com/nianticlabs/spz.git
cd spz
pip install .README 未说明显存或 GPU 要求,仅说明 C++ 库依赖 libz 与 libzstd,未提 CPU 或 GPU 型号限制
Niantic 开源的 3D 高斯泼溅压缩文件格式与 C++ 读写库,体积约为 PLY 的十分之一
Niantic 开源的 3D 高斯泼溅压缩文件格式,体积比 PLY 小约 10 倍,视觉质量几乎无损,适合存储和分发大规模 3DGS 场景。
核心能力
- 用 ZSTD 分属性流独立压缩,支持并行解压
- 提供 saveSpz/loadSpz 的 C++ 读写 API
- 内置 16 种命名坐标系及转换,含 SH 系数旋转
- 可调 SH 量化位数,默认 5/4 bit
- 支持 Emscripten 编译为 WASM 供 TypeScript 调用
容易踩的坑
- v3.0.0最新正式版2026-05-05 · 2026-05-05 05:26 UTC
What's Changed
- Add BUILD_TOOLS option, enable C++17 for CLI targets by @kring in https://github.com/nianticlabs/spz/pull/63
- Update README.md by @azadbal in https://github.com/nianticlabs/spz/pull/65
- Integrate Vendor-specific SPZ Extensions, WASM Bindings, and CMake Improvements (Backward-Compatible) by @raymondyfei in https://github.com/nianticlabs/spz/pull/67
- Performance: Optimization for C++/JS Data Transfer by @raymondyfei in https://github.com/nianticlabs/spz/pull/74
- Switch SPZ compression from GZip to ZSTD with parallel multi-stream encoding by @udwinj in https://github.com/nianticlabs/spz/pull/73
- Reinstate Backwards Compatibility Writing by @lukeyreyno in https://github.com/nianticlabs/spz/pull/76
- Move V4 Extensions to Memory Space between Header and TOC by @lukeyreyno in https://github.com/nianticlabs/spz/pull/77
- [ci] Run Python tests on macOS by @RiyaanB in https://github.com/nianticlabs/spz/pull/78
- Install headers to spz prefix by @hobu in https://github.com/nianticlabs/spz/pull/48
- [perf] Use std::nth_element for medianVolume() by @RiyaanB in https://github.com/nianticlabs/spz/pull/79
New Contributors
- @kring made their first contribution in https://github.com/nianticlabs/spz/pull/63
- @udwinj made their first contribution in https://github.com/nianticlabs/spz/pull/73
- @lukeyreyno made their first contribution in https://github.com/nianticlabs/spz/pull/76
- @RiyaanB made their first contribution in https://github.com/nianticlabs/spz/pull/78
Full Changelog: https://github.com/nianticlabs/spz/compare/v2.1.0...v3.0.0
- v2.1.02025-10-27 · 2025-10-27 22:37 UTC
查看更新说明
What's Changed
- Add CODEOWNERS by @daniel-niantic-spatial in https://github.com/nianticlabs/spz/pull/44
- Add BUILD_SHARED_LIBS CMake option by @hobu in https://github.com/nianticlabs/spz/pull/47
- Link android log lib by @dg0yt in https://github.com/nianticlabs/spz/pull/55
- Implement CLI tools for PLY to SPZ conversion and vice versa, along w… by @takeru in https://github.com/nianticlabs/spz/pull/29
- add python bindings by @qureshizawar in https://github.com/nianticlabs/spz/pull/54
- Fix PIC compilation error when building Python bindings by @FryeGao in https://github.com/nianticlabs/spz/pull/59
- Use size_t for finding
medianVolumeto eliminate integer comparison warning by @hobu in https://github.com/nianticlabs/spz/pull/50 - Add GitHub Action configuration to build on Windows, OSX, and Ubuntu by @hobu in https://github.com/nianticlabs/spz/pull/49
- Ignore comment lines when reading .ply header by @nlml in https://github.com/nianticlabs/spz/pull/61
- Add overload for
loadSpzto take byte pointer by @azrogers in https://github.com/nianticlabs/spz/pull/62
New Contributors
- @daniel-niantic-spatial made their first contribution in https://github.com/nianticlabs/spz/pull/44
- @hobu made their first contribution in https://github.com/nianticlabs/spz/pull/47
- @takeru made their first contribution in https://github.com/nianticlabs/spz/pull/29
- @qureshizawar made their first contribution in https://github.com/nianticlabs/spz/pull/54
- @FryeGao made their first contribution in https://github.com/nianticlabs/spz/pull/59
- @nlml made their first contribution in https://github.com/nianticlabs/spz/pull/61
- @azrogers made their first contribution in https://github.com/nianticlabs/spz/pull/62
Full Changelog: https://github.com/nianticlabs/spz/compare/v2.0.0...v2.1.0
- v2.0.02025-07-11 · 2025-07-11 20:36 UTC
查看更新说明
What's Changed
- Update README.md by @azadbal in https://github.com/nianticlabs/spz/pull/27
- Add CMake build system by @Meakk in https://github.com/nianticlabs/spz/pull/8
- fix boundary issue in PackedGaussians::at(int i) by @fortmeier in https://github.com/nianticlabs/spz/pull/18
- Fix for Windows and CPP17 compatibility by @raymondyfei in https://github.com/nianticlabs/spz/pull/13
- Add find_dependency(ZLIB) by @dg0yt in https://github.com/nianticlabs/spz/pull/39
- Add spz::spz alias target by @dg0yt in https://github.com/nianticlabs/spz/pull/40
- Version 3 with "smallest three" quaternion encoding on 4 bytes by @jeanphilippepons in https://github.com/nianticlabs/spz/pull/41
New Contributors
- @Meakk made their first contribution in https://github.com/nianticlabs/spz/pull/8
- @fortmeier made their first contribution in https://github.com/nianticlabs/spz/pull/18
- @raymondyfei made their first contribution in https://github.com/nianticlabs/spz/pull/13
- @dg0yt made their first contribution in https://github.com/nianticlabs/spz/pull/39
- @jeanphilippepons made their first contribution in https://github.com/nianticlabs/spz/pull/41
Full Changelog: https://github.com/nianticlabs/spz/compare/v1.1.0...v2.0.0
- v1.1.02025-04-18 · 2025-04-18 21:04 UTC
查看更新说明
What's Changed
- Fix README.md typo by @liorazi in https://github.com/nianticlabs/spz/pull/3
- Fix file format description in readme by @aras-p in https://github.com/nianticlabs/spz/pull/16
- Update README.md with Discord link. by @azadbal in https://github.com/nianticlabs/spz/pull/23
- Adding Niantic Internal changes. by @ProjitB in https://github.com/nianticlabs/spz/pull/25
- Changed int to int32_t
- Coordinate system conversions
- These changes are not backward compatible as interfaces changed.
New Contributors
- @liorazi made their first contribution in https://github.com/nianticlabs/spz/pull/3
- @aras-p made their first contribution in https://github.com/nianticlabs/spz/pull/16
- @azadbal made their first contribution in https://github.com/nianticlabs/spz/pull/23
- @ProjitB made their first contribution in https://github.com/nianticlabs/spz/pull/25
Full Changelog: https://github.com/nianticlabs/spz/compare/v1.0.0...v1.1.0
- v1.0.02025-04-18 · 2025-04-18 20:10 UTC
查看更新说明
Initial release of SPZ file format.
What's Changed
- [spz] Sync spz 2024-10-02. by @nbutko in https://github.com/nianticlabs/spz/pull/1
- [spz] Sync spz 2024-10-28 by @nbutko in https://github.com/nianticlabs/spz/pull/2
New Contributors
- @nbutko made their first contribution in https://github.com/nianticlabs/spz/pull/1
Full Changelog: https://github.com/nianticlabs/spz/commits/v1.0.0
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
spz
.spz is a file format for compressed 3D gaussian splats. This directory contains a C++ library
for saving and loading data in the .spz format.
spz encoded splats are typically around 10x smaller than the corresponding .ply files, with minimal visual differences between the two.
Internals
Coordinate System
By default, SPZ stores data in an RUB coordinate system following the OpenGL and three.js
convention. This can be overridden via the SPZ_ADOBE_coordinate_system extension, which allows
data to be stored in any named coordinate system (see extensions/README.md). This differs from other data formats such as PLY (which typically uses RDF), GLB (which
typically uses LUF), or Unity (which typically uses RUF). To aid with coordinate system conversions,
callers should specify the coordinate system their Gaussian Cloud data is represented in when saving
and what coordinate system their rendering system uses when loading. These are specified in the
PackOptions and UnpackOptions respectively. If the coordinate system is UNSPECIFIED, data will
be saved and loaded without conversion, which may harm interoperability.
There are 16 named coordinate systems organised in two families:
- Standard family — letters denote the X, Y, Z axis directions (e.g.
RUB= Right, Up, Back):LDB,RDB,LUB,RUB,LDF,RDF,LUF,RUF - Rotated family — axes are permuted by a 90-degree rotation about X (Y and Z are swapped):
LFD,RFD,LFU,RFU,LBD,RBD,LBU,RBU
Converting between families applies a 90-degree rotation about the X axis in addition to any axis flips, which also rotates spherical-harmonics coefficients via the appropriate Wigner D-matrix.
Implementations
C++
Requires libz and libzstd as dependent libraries, otherwise the code is completely self-contained.
A CMake build system is provided for convenience.
Note: If libz or libzstd are not found on the system, the CMake build system will automatically download them using FetchContent. This ensures consistent builds across different environments.
Typescript
To build the Typescript interface through Web-Assembly (WASM), an Emscripten environment needs to be setup before compilation. One may install the Emscripten SDK following the instructions here.
Under an emscripten environment, the Makefile can be generated through:
emcmake cmake -B build-wasm .
Then one can build through
cmake --build build-wasm
The package will be built and installed into the dist folder.
API
C++
bool saveSpz(
const GaussianCloud &gaussians, const PackOptions &options, std::vector<uint8_t> *output);
Converts a cloud of Gaussians to .spz format and writes the result to a vector of bytes.
gaussians: The Gaussians to saveoptions: Flags that control the packing behavior, including SH quantization parameters.output: A vector that will be populated with bytes encoded in .spz format- Returns true on success and false on failure.
bool saveSpz(
const GaussianCloud &gaussians, const PackOptions &options, const std::string
&filename);
Saves a cloud of Gaussians in .spz format to a file
gaussians: The Gaussians to saveoptions: Flags that control the packing behavior, including SH quantization parameters.filename: The path to the file to save to.- Returns true on success and false on failure.
GaussianCloud loadSpz(const std::vector<uint8_t> &data, const UnpackOptions &opti
ons);
Loads a cloud of Gaussians from bytes in .spz format.
data: A vector containing the encoded spz dataoptions: Flags that control the unpacking behavior.- Returns a
GaussianClouddecoded from the vector. In case of an error, this will return a result with no gaussians
GaussianCloud loadSpz(const std::string &filename, const UnpackOptions &options);
Loads a cloud of Gaussians from a file in .spz format.
filename: The path to the file to load from.options: Flags that control the unpacking behavior.- Returns a
GaussianClouddecoded from the file. In case of an error, this will return a result with no gaussians
Typescript
Check src/emscripten/spz.d.ts.in (source) or dist/spz.d.ts (after building with CMake) for the TypeScript interface. Since the Emscripten and Javascript memory are separately handled, we only expose limited functionalities for the Typescript interface.
PackOptions
The PackOptions struct supports the following fields:
from: Source coordinate system (default:UNSPECIFIED)version: Version of the packed format (default:4)sh1Bits: Number of quantization bits for SH degree 1 coefficients (default: 5, range: 1-8)shRestBits: Number of quantization bits for SH degree 2+ coefficients (default: 4, range: 1-8)
File Format
Version 4 uses ZSTD compression with a 32-byte plaintext header. Each attribute stream is compressed independently and in parallel, improving both compression and decompression throughput. Files from versions 1–3 (gzip-compressed single-stream format) can still be read. There is no maximum point count enforced during loading.
File layout (version 4)
Bytes 0–31: NgspFileHeader (32 bytes, plaintext)
Bytes 32..(tbo-1): Extension ILV records, if flags & 0x2 (variable)
Bytes tbo..(tbo+N*16-1): TOC — N × [compressedSize u64, uncompressedSize u64]
Bytes (tbo+N*16)..end: N independent ZSTD-compressed attribute streams
tbo = tocByteOffset from the header. When no extensions are present, tbo = 32.
Header (version 4)
struct NgspFileHeader { // 32 bytes, all fields little-endian
uint32_t magic; // 0x5053474e ("NGSP")
uint32_t version; // 4
uint32_t numPoints;
uint8_t shDegree;
uint8_t fractionalBits;
uint8_t flags;
uint8_t numStreams; // number of ZSTD-compressed attribute streams (typically 6)
uint32_t tocByteOffset; // byte offset from file start to the TOC
uint8_t reserved[12]; // zero, reserved for future use
};
All values are little-endian.
- magic: Always
0x5053474e(bytesN,G,S,Pin file order). - version: 4 (current). Versions 1–3 use the legacy gzip format (read-only).
- numPoints: The number of gaussians.
- shDegree: The degree of spherical harmonics. Must be between 0 and 4 (inclusive).
- fractionalBits: The number of bits used for the fractional part of fixed-point coordinates.
- flags: Bit field.
0x1: splat was trained with antialiasing.0x2: the header zone contains vendor-specific extension records (see Extensions).
- numStreams: Number of ZSTD-compressed attribute streams following the TOC. Typically 6 (positions, alphas, colors, scales, rotations, spherical harmonics).
- tocByteOffset: Byte offset from the start of the file to the Table of Contents. Everything before
tocByteOffsetis plaintext. - reserved: Must be zero.
Format detection (load path)
bytes[0..3] == "NGSP" → version 4 ZSTD format
bytes[0..1] == 0x1f 0x8b → legacy gzip format (versions 1–3, read-only)
Positions
Positions are represented as (x, y, z) coordinates, each as a 24-bit fixed point signed integer.
The number of fractional bits is determined by the fractionalBits field in the header.
Scales
Scales are represented as (x, y, z) components, each represented as an 8-bit log-encoded integer.
Rotation
In version 3 and 4, rotations are represented as the smallest three components of the normalized rotation quaternion, for optimal rotation accuracy. The largest component can be derived from the others and is not stored. Its index is stored on 2 bits and each of the smallest three components is encoded as a 10-bit signed integer.
In version 2, rotations are represented as the (x, y, z) components of the normalized rotation quaternion. The
w component can be derived from the others and is not stored. Each component is encoded as an
8-bit signed integer.
Alphas
Alphas are represented as 8-bit unsigned integers.
Colors
Colors are stored as (r, g, b) values, where each color component is represented as an
unsigned 8-bit integer.
Spherical Harmonics
Depending on the degree of spherical harmonics for the splat, this can contain 0 (for degree 0), 9 (for degree 1), 24 (for degree 2), 45 (for degree 3), or 72 (for degree 4) coefficients per gaussian.
The coefficients for a gaussian are organized such that the color channel is the inner (faster varying) axis, and the coefficient is the outer (slower varying) axis, i.e. for degree 1, the order of the 9 values is:
sh1n1_r, sh1n1_g, sh1n1_b, sh10_r, sh10_g, sh10_b, sh1p1_r, sh1p1_g, sh1p1_b
Each coefficient is represented as an 8-bit signed integer.
Quantization:
SPZ supports configurable spherical harmonics quantization. By default, a fixed-precision quantization is adopted:
- Assumes SH coefficients are in the [-1, 1] range
- Fixed 5 bits of precision for degree 1 and 4 bits for degrees 2, 3, and 4
- Maintained for backward compatibility
The quantization precision can be configured via PackOptions:
sh1Bits: Number of quantization bits for SH degree 1 coefficients (default: 5, range: 1-8)shRestBits: Number of quantization bits for SH degree 2+ coefficients (default: 4, range: 1-8)
Note: Quantization bits are only used during packing to reduce information entropy for better compression. The unpacking process does not need to know the exact quantization bits, as decompression fills zero bits for quantized data automatically.
This allows users to trade off between file size and quality. The library maintains full backward compatibility with default quantization settings.
Extensions
SPZ supports vendor-specific extensions (e.g. camera limits) so multiple vendors can coexist in the same file. In version 4, extensions are stored as ILV (type + length + value) records in the plaintext header zone between the fixed header and the TOC — parsers that don't recognize an extension type skip it by length. For the extension format and how to add or use extensions, see extensions/README.md.
Camera Orbit Limitation
With extension SPZ_ADOBE_safe_orbit_camera, SPZ supports storing camera limits which can be used to restrict the view in a render. This extension includes:
Attributes
This extension has the following attributes and default values:
float safeOrbitElevationMin = 0.0f; // Minimum elevation for safe orbit (radians)
float safeOrbitElevationMax = 0.0f; // Maximum elevation for safe orbit (radians)
float safeOrbitRadiusMin = 0.0f; // Minimum radius for safe orbit
Georeferencing
With extension SPZ_NIANTIC_georeference, SPZ can store a similarity transform (origin, unit quaternion rotation, uniform scale) that maps the asset's RUB positions into a geocentric CRS, named by an AUTHORITY:CODE such as EPSG:4978 (WGS 84 ECEF) or by inline PROJJSON, with an optional coordinate epoch. The library never applies the transform. See extensions/README.md for the payload layout and validation rules.
Python Bindings
The SPZ library provides Python bindings built with nanobind that offer a convenient interface for loading, manipulating, and saving 3D Gaussian splats from Python.
Installation
git clone https://github.com/nianticlabs/spz.git
cd spz
pip install .
Please see src/python/README.md for more details and usage examples
Web Utility
A browser-based utility is available at nianticlabs.github.io/spz. It uses the latest WASM build and allows you to inspect file metadata for .spz and .ply files and convert between the two formats without installing anything. As it runs entirely in the browser, it is subject to browser memory limits and is intended for files up to around 2 GB. For larger files, clone the repository and use the command-line tools directly.