Introduction
SOG (Spatially Ordered Gaussians) is a compressed format for Gaussian splat scenes
from PlayCanvas. It stores each attribute of the
splats as the pixels of an image, one pixel a splat, saved as lossless WebP, with a
meta.json file that says how to turn the pixels back into values. The
images compress well because the splats are sorted so that neighbouring pixels hold
splats that are close together in space.
A SOG scene is either a folder of these files or a ZIP archive of them, usually
named .sog. The description below is of version 3, the current one;
versions 2 and 1 differ as listed after it. The file explorer
opens a .sog archive: it shows the ZIP structure, every image
decoded as a picture, the meta.json fields, and the scene itself as splats, from the
images’ pixels (see Images). A folder is a set of separate files,
and the explorer takes one file at a time, so it needs the folder zipped.
Structure
meta.jsonMetadata version, splat count, ranges, codebooks and the names of the imagesJSONmeans_l.webpPositions, low bytes x, y, z in red, green, bluea pixel a splatmeans_u.webpPositions, high bytes x, y, z in red, green, bluea pixel a splatquats.webpRotations in red, green, bluea pixel a splatscales.webpScales codebook indices for x, y, za pixel a splatsh0.webpColour and opacity codebook indices in red, green, blue; opacity in alphaa pixel a splatshN_centroids.webpHarmonics palette optional64 entries a rowshN_labels.webpHarmonics labels optional: each splat’s palette entrya pixel a splat
Every per-splat image has the same size, and splat i is the pixel at x = i mod W, y = ⌊i / W⌋, counting from the top left, for an image W pixels wide. The image may have more pixels than there are splats; the extra ones are ignored. The images must be lossless, because lossy compression would change the values.
Images
Every image is a WebP file: a RIFF container (RIFF, a size,
WEBP) around one VP8L chunk, which is WebP’s lossless
coding (RFC 9649). The chunk
starts with the byte 0x2F, then 14 bits of width − 1, 14 bits of height − 1, a bit
saying whether alpha is used and 3 bits of version (0). The pixels follow as four
8-bit channels, each byte of an image being the value the format needs, so no colour
conversion may happen between the file and the numbers. Three details matter:
- Images that list only red, green and blue are written with alpha 255 and a reader
ignores their alpha. Only
sh0and blind textures use alpha for data. - A lossless encoder may throw away the colour of fully transparent pixels. A blind
texture whose alpha byte holds data (and may be 0) must be written with that
colour kept (libwebp’s
exactoption). - A browser that multiplies the decoded colour by alpha loses precision wherever alpha is under 255, and all colour where it is 0, which is why the format gives alpha so little data.
VP8L codes an image with up to four transforms (a predictor, a colour transform,
subtract-green and a colour table), a colour cache, LZ77 back references and prefix
codes that can change by block. The explorer decodes all of these itself and
lists the transforms each image uses in its Images table; it has been checked against
libwebp on every kind. A lossy WebP image (a VP8 chunk) is outside the
format: the explorer reports it and does not decode it.
meta.json
| Key | Value |
|---|---|
version | 3 (2 in the previous version; version 1 has no such key) |
count | The number of splats |
asset.generator | The tool that wrote the scene; optional |
model | "antialiased" or "2dgs"; left out for ordinary splats |
means | mins and maxs, three numbers each, and files |
scales | codebook, 256 numbers, and files |
quats | files |
sh0 | codebook, 256 numbers, and files |
opacity | max, only when an opacity is above 1 |
shN | Optional: count (palette entries), bands (1 to 4), codebook (256 numbers) and files |
blind | Optional: a list of textures, each with files (one image) and fields, described below |
extras | Optional: any JSON, for the application; tools should carry it through unchanged |
comments | Optional: a list of free-form text lines from the producer, such as the comment lines of the PLY it was made from; informational only |
Readers ignore keys they do not know. The names in each files list are
arbitrary and their order matters: means.files is the low image, then the
high one, and shN.files is the palette, then the labels. count
must not exceed the pixels in an image, and trailing pixels are ignored.
From the pixels to a Gaussian
- Position: for each axis, the high byte from
means_uand the low byte frommeans_lmake a 16-bit value q. Interpolate fromminstomaxsby q / 65535 to get n, then undo the log transform: sign(n) × (e|n| − 1). - Rotation: each byte b of red, green and blue gives p = (b − 128) / 127, a vector (px, py, pz). With r its length and θ = π/2 × r, the quaternion is w = cos θ and (x, y, z) = p × sin θ / r (zero when r is 0). The bytes 128, 128, 128 are no rotation.
- Scale: each channel is an index into the scales codebook, which holds logarithms; the scale is e to the power of the entry.
- Colour: each of red, green and blue in
sh0is an index into the sh0 codebook, and the colour is 0.5 + entry ×SH_C0, withSH_C0= 1 / (2√π). - Opacity: (A / 204)², from the alpha byte A of
sh0. 204 is an opacity of 1, and 255 about 1.5625, which a scene can use for splats that stand for several merged ones.
Spherical harmonics
The harmonics above degree 0 are shared through a palette. Each splat’s label in
shN_labels is red + green × 256 + blue × 65536, the number of its
palette entry. A palette entry has 3, 8, 15 or 24 coefficients a channel for 1, 2, 3 or
4 bands. shN_centroids holds 64 entries a row, so it is
64 × coefficients wide: coefficient c of entry n is the pixel
at u = (n mod 64) × coefficients + c,
v = ⌊n / 64⌋. Its red, green and blue are indices into the
shN codebook for the three channels.
Version 2
| Version 2 | Version 3 | |
|---|---|---|
| Rotation | Smallest three, 26 bits in quats.webp | The vector in red, green and blue described above |
| Opacity | sh0 alpha / 255, at most 1 | (alpha / 204)², at most 1.5625 |
| Harmonics bands | 1 to 3 | 1 to 4 |
| Palette | Up to 65,536 entries, 16-bit labels | Up to 224 entries, 24-bit labels |
| blind, extras, comments, model | Not present | Present |
Positions, scales, base colours, the palette layout and the file layout are the same in both. In version 2 the rotation is read like this: red, green and blue hold three components of the quaternion in the order w, x, y, z, as (b / 255 − 0.5) × 2 / √2, and alpha holds 252 plus the index (0 to 3, in the order w, x, y, z) of the component that is left out, because it was the largest. That component is √(1 − the sum of the others squared), and positive. An alpha under 252 is reserved.
Version 1 (an early layout that files from before the version field still use)
has no version and no count; the count is
means.shape[0], and the shape, dtype and encoding
keys describe the images. Nothing goes through a codebook:
- Positions are as in version 3 (16 bits an axis from
means_landmeans_u, betweenminsandmaxs, then the inverse of the log transform). - Scales: each byte is a linear step between
scales.minsandscales.maxsfor its axis, giving the logarithm of the scale. - Rotation: as in version 2 (splat-transform’s version 1 reader writes the scaling as b / 255 × 2 − 1, which is the same number).
- Colour and opacity: each byte of
sh0is a step betweensh0.minsandsh0.maxs(four numbers each); red, green and blue give the base coefficient, alpha gives the opacity as a logit, so the opacity is 1 / (1 + e−v). - Harmonics:
shNhasminsandmaxs(one number each, for every coefficient) and no band count: the width ofshN_centroidssays it (192, 512 or 960 pixels for 1, 2 or 3 bands). The centroid bytes are steps between those two numbers, and the labels are 16-bit.
Some files that say version 2 leave out shN.count and
shN.bands too (the published skull.sog does); readers take the band count from the
width of the centroids image and the palette size from its height, the way they do for version 1.
Opacity above 1
Version 3 can store an opacity A up to 1.5625 (alpha byte 255), for a
splat that stands in for several merged ones and so carries more than a standard
Gaussian’s total weight. opacity.max in meta.json is present exactly
when some splat is above 1. The file stores only A; how it is drawn is the
renderer’s choice. PlayCanvas draws a splat with A over 1 with an opaque core and
the usual falloff outside it, solved so that the mass is A times a standard splat’s. A
renderer that does not support this clamps A to 1, as the explorer’s pictures do.
A PLY converted from such a scene keeps A in a property opacity_linear
in place of opacity, and a reader that finds it uses it as the opacity.
Blind data
Version 3 can carry data of the application’s own per splat (an object number, a
segment, a weight). Each entry of blind is one RGBA texture, and its
fields are packed into the four bytes of each pixel in order, red first, each
field little-endian: u8, u16, u24,
u32 (1 to 4 bytes, unsigned), f16 and f32 (IEEE
half and single floats), and unorm8 and unorm16, which map
the code 0 to the top code onto range (default 0 to 1). The fields must fit
in 4 bytes and have unique names, and bytes after the last field are unused. A texture
whose fields use the alpha byte can contain alpha 0, so it must be encoded with its
colour kept. The explorer lists each field with the smallest and largest value in the
scene; it does not draw them.
Worked example
The first splat of the playbot scene in PlayCanvas’s engine examples
(version 2, 1,873 splats, images 44 × 44 pixels; pixel 0 of each image):
| Image | Pixel (R, G, B, A) | Decoded |
|---|---|---|
means_l, means_u | (178, 204, 245, 255) and (1, 236, 1, 255) | 16-bit values 434, 60620 and 501 (high byte × 256 + low byte); with the meta’s mins and maxs the log-domain values are −0.69505, −0.02078 and −0.69409, and the position −1.0038, −0.0210, −1.0019 |
scales | (35, 133, 144, 255) | codebook entries −7.5842, −4.5822 and −4.2536; the scales e to those: 0.000508, 0.010233 and 0.014213 |
quats | (242, 158, 181, 255) | mode 255 − 252 = 3, so z was largest; the three kept are 0.6350, 0.1692 and 0.2967 (w, x, y); z = √(1 − 0.5199) ≈ 0.6929 |
sh0 | (68, 64, 68, 254) | codebook entries −1.2572, −1.3011 and −1.2572, so the colour is 0.5 − 1.2572 × 0.2821 = 0.1453, 0.1330 and 0.1453; opacity 254 / 255 = 0.9961 |
Not described
The page follows PlayCanvas’s specifications of versions 3 and 2 and the code of splat-transform and the engine for version 1. The explorer reads the files from the images’ pixels; these parts it does not cover.
Known, not yet covered
- Viewer: lossy WebP images (a
VP8chunk, RFC 6386). The format forbids them, and the explorer reports the image and draws no scene instead of showing damaged values; only the VP8 frame header is read. - Viewer: the
antialiasedand2dgsmodels are named but drawn as ordinary Gaussians, and opacity above 1 is drawn as 1 (the reference describes a renderer’s profile, not a stored value). - Viewer: splats with 4 bands of harmonics are decoded and listed, but the pictures use only the first 3 bands.
- Viewer: a folder of loose files (the explorer opens one file at a
time) and a
meta.jsonon its own, which is shown as JSON. - Viewer: checked on real files of versions 1, 2 and 3 (the engine’s playcanvas-logo, playbot, skull and the version 3 logo with blind data) and on built files, but not on a version 3 scene with harmonics, for which no real file was found.
Unknown
- Reference: the
lod-meta.jsonlayout of the engine’s streamed, levels-of-detail SOG sets (the playbot example folders). It is not part of the SOG specification and no document describing it was found.
Links
Software
- SuperSplat – PlayCanvas’s free open source splat editor (web)
Developers
- splat-transform – converts splat scenes to and from SOG (JavaScript)
- PlayCanvas engine – web 3D engine that loads and draws SOG scenes (JavaScript)
Reference
- SOG format – PlayCanvas’s specification of version 3, with the changes from version 2
- SOG format, version 2 – PlayCanvas’s specification of the previous version
- RFC 9649 – the WebP image format, container and lossless coding