This page follows Niantic’s library: load-spz.cc, which reads and writes
the format, and splat-utils.h, which holds the conversions. A file of
versions 1 to 3 is a single gzip member whose contents are laid out as below. All
numbers are little-endian.
The header
| Offset | Size | Type | Field | Meaning |
|---|---|---|---|---|
| 0 | 4 | uint32 | magic | 0x5053474E, the bytes NGSP |
| 4 | 4 | uint32 | version | 1, 2 or 3 (the library reads these; version 1 is the oldest, with half-float positions) |
| 8 | 4 | uint32 | numPoints | The number of splats, at least 1 |
| 12 | 1 | uint8 | shDegree | The spherical harmonics degree, 0 to 4 |
| 13 | 1 | uint8 | fractionalBits | The bits after the binary point in the positions; the library writes 12 |
| 14 | 1 | uint8 | flags | Bit 0 (0x01): the scene was trained with antialiasing. Bit 1 (0x02): extension records follow the harmonics, at the end of the data (see Extensions) |
| 15 | 1 | uint8 | reserved | 0 |
The attributes follow at offset 16, each for every splat before the next attribute starts. The library rejects a count above what the remaining bytes can hold (at least 9 bytes of positions for each splat), a count of 0 or above 231 − 1, and a degree above 4. The explorer also checks that the data holds as many bytes as the counts need.
Positions
Versions 2 to 4 store each coordinate as a signed 24-bit integer, three bytes,
least significant first: x, y and z of splat 0, then of splat 1, and so on. The
coordinate is the integer divided by 2fractionalBits; with 12
bits that is a step of 1/4096 and a reach of ±2048. Version 1 stores three half
floats instead, 6 bytes a splat.
Alphas
One byte a splat: the opacity after the sigmoid, times 255. A reader that wants the PLY file’s value takes the inverse sigmoid, ln(a / (1 − a)), of a = byte / 255.
Colours
Three bytes a splat: red, green and blue. Each holds the degree 0 spherical harmonics
coefficient f_dc, scaled by 0.15 and centred: the coefficient is
(byte / 255 − 0.5) / 0.15. The base colour is then
0.5 + SH_C0 × coefficient, with SH_C0 = 0.2820948, as in the
PLY layout.
Scales
Three bytes a splat, one an axis: the natural logarithm of the scale, as byte / 16 − 10. Bytes 0 to 255 cover logarithms from −10 to about 5.9, a scale from 0.000045 to about 370.
Rotations
Versions 1 and 2 store 3 bytes a splat: the x, y and z of the normalised quaternion, each as byte / 127.5 − 1. The writer first makes w positive, so the reader takes w = √(1 − x² − y² − z²).
Version 3 stores 4 bytes a splat, a 32-bit word in the “smallest three” form, which is more precise:
31–30Largest which of x, y, z, w (0 to 3) is left out2 bits29–20First kept component sign bit, then 9 bits of magnitude10 bits19–10Second kept component sign bit, then 9 bits of magnitude10 bits9–0Third kept component sign bit, then 9 bits of magnitude10 bits
The kept components are in the order x, y, z, w, leaving out the largest. Each has a sign in its top bit and a magnitude m in the other nine, meaning m / 511 × √½. The writer negates the quaternion first if the largest component is negative, so the reader takes the largest as the positive √(1 − the sum of the other three squared).
Spherical harmonics
When the degree is 1 or more, each splat has 3, 8, 15 or 24 coefficients a channel for degree 1, 2, 3 or 4, so 9, 24, 45 or 72 bytes. Unlike the PLY layout, the channel varies fastest: red, green and blue of coefficient 1, then red, green and blue of coefficient 2, and so on, in the coefficient order of the PLY layout. Each byte v stands for (v − 128) / 128. The writer keeps 5 bits of precision for degree 1 and 4 bits for the higher degrees by default, rounding the low bits away, which helps the compression.
Worked example
splat-transform’s test file minimal-v3.spz, four splats, decompressed
from its gzip (96 bytes). The header is
4E 47 53 50 | 03 00 00 00 | 04 00 00 00 | 00 | 0C | 00 | 00: version 3,
4 splats, degree 0, 12 fractional bits, no flags. The positions start at offset 16.
Splat 0 is 00 F0 FF | 00 00 00 | 00 10 00: x is 0xFFF000, which is
−4096 as a signed 24-bit number, divided by 4096: −1; y is 0; z is 0x001000 = 4096,
so 1. Its alpha (offset 52) is E6 = 230, an opacity of 230 / 255 = 0.902. Its colour (offset 56) is
69 69 80: (105 / 255 − 0.5) / 0.15 = −0.588 for red and green, and
(128 / 255 − 0.5) / 0.15 = 0.013 for blue, so the base colour is 0.5 + 0.2821 ×
−0.588 = 0.334 (red and green) and 0.504 (blue). Its scales (offset 68) are
7B 7B 7B: 123 / 16 − 10 = −2.3125, a scale of e−2.3125 =
0.099. Its rotation (offset 80) is the word 00 00 00 C0 = 0xC0000000:
the top two bits are 3, so w is the left-out largest, and the three 10-bit values are 0
(sign 0, magnitude 0), so w = 1: no rotation.
Coordinates
The library’s own coordinate system is right, up, back (RUB): +Y up, the convention of OpenGL and three.js. Its functions convert from and to other systems when asked, including the right, down, forward system of the training code’s PLY files; when no system is given, no conversion is done.
Version 4
Version 4 drops gzip, and a reader tells the two apart by the first bytes:
NGSP is version 4, 1F 8B is gzip. The file is a 32-byte
header in the clear, extension records, a table of contents and the Zstandard streams
(RFC 8878), each attribute compressed on its own so that they decompress in
parallel. There is no limit on the number of splats.
| Offset | Size | Type | Field | Meaning |
|---|---|---|---|---|
| 0 | 4 | uint32 | magic | 0x5053474E, NGSP |
| 4 | 4 | uint32 | version | 4 |
| 8 | 4 | uint32 | numPoints | The number of splats |
| 12 | 1 | uint8 | shDegree | 0 to 4 |
| 13 | 1 | uint8 | fractionalBits | The bits after the binary point in the positions |
| 14 | 1 | uint8 | flags | Bit 0: antialiased. Bit 1: extension records between the header and the table of contents |
| 15 | 1 | uint8 | numStreams | How many Zstandard streams follow the table of contents: usually 6, 5 without harmonics |
| 16 | 4 | uint32 | tocByteOffset | Where the table of contents starts: 32 when there are no extensions |
| 20 | 12 | bytes | reserved | Zero |
The table of contents has one entry a stream, two uint64 each: the compressed size and the uncompressed size. The streams follow it, in the order positions, alphas, colours, scales, rotations, spherical harmonics, leaving out empty ones (no harmonics at degree 0). Each stream is one Zstandard frame. The attributes inside are the ones above, except that positions are always 9 bytes a splat (24-bit) and rotations always the 4-byte smallest-three form. The streams must fill the file: the sizes of the compressed streams add up to the bytes after the table of contents.
Extensions
Extensions let a vendor add data to a file; a reader skips the ones it does not know.
Each is a record: a uint32 type, a uint32 byte length and that many
bytes of payload. The type is a vendor number in its top 16 bits (0xADBE is Adobe,
0x4E53 is Niantic) and the vendor’s own extension number in the low 16. In
version 4 the records fill the bytes from 32 to tocByteOffset, with flag
bit 1 set. Files of versions 2 and 3 can have records too: with flag bit 1 set they
follow the harmonics at the end of the decompressed data and run to its end.
| Type | Name | Payload |
|---|---|---|
| 0xADBE0002 | SPZ_ADOBE_safe_orbit_camera | Three float32: the lowest and highest camera elevation in radians, and the smallest orbit radius; a viewer can keep the camera inside them |
| 0xADBE0003 | SPZ_ADOBE_coordinate_system | One uint32, 1 to 16: the coordinate system the file’s positions, rotations and harmonics are stored in (below). A label, not an instruction: readers must not convert again |
| 0x4E530001 | SPZ_NIANTIC_georeference | A similarity transform from the splats’ RUB positions into a geocentric coordinate reference system: origin (3 float64, metres), rotation (a unit quaternion x y z w, 4 float64), scale (float64, above 0) and epoch (a float64 decimal year, NaN when the flag says none), after a 4-byte start (uint8 version 1, uint8 flags: bit 0 has an epoch, bits 1 and 2 how the CRS is written: 0 an AUTHORITY:CODE such as EPSG:4978, 1 an inline PROJJSON; uint16 length of the CRS text); the text, not terminated, follows the 76 bytes. A position in the target is scale × (rotation applied to p) + origin |
| 0x4E530002 | SPZ_NIANTIC_custom_attribute | A named per-splat attribute. uint16 name length and the name (printable ASCII), uint16 dim (floats a splat), uint8 semantic (0 custom, 1 spatial, which is converted with the positions and needs a multiple of 3), uint8 bits (32 for float32 values, 1 to 16 for quantised levels), for quantised values dim float32 minimums and dim maximums, a uint32 frame count and, for each extension frame, three uint64: its offset from the start of the last stream, its payload size and its decompressed size. The values are component by component, each as bytes planes (low bytes of every splat, then high bytes). Readers drop an attribute with a name used twice or values of the wrong total size |
The coordinate systems are named by three letters for the direction of the three axes, in the order x, y, z: L or R, U or D, F or B (left, right, up, down, front, back) for numbers 1 to 8 (LDB, RDB, LUB, RUB = 4, the default, LDF, RDF = 6 like PLY, LUF = 7 like glTF, RUF = 8 like Unity), and for 9 to 16 the same eight with the y and z axes swapped by a quarter turn about x (LFD, RFD, LFU, RFU, LBD, RBD, LBU, RBU). Without an extension the file is RUB. Converting between systems flips axes and rotates the harmonics coefficients accordingly.
Extension frames
Bulk data of an extension (the values of a custom attribute) does not fit in the clear zone, so it goes after the last stream’s Zstandard frame, inside the range the table of contents gives that stream. Each part is a Zstandard skippable frame: the magic 0x184D2A53, a uint32 payload size, and a payload that is exactly one Zstandard frame holding up to 16 MiB of the data. A Zstandard decoder skips skippable frames, so a reader that knows nothing of the extension decompresses the last stream and gets only its own data. The record lists each frame’s position, so the attribute’s data is the payloads decompressed and joined in that order. A frame that is not entirely inside the last stream, that starts before the stream’s own frame ends or whose size does not match its record is dropped, and the core data still loads.