Specification (.ss v1)
This page shows spec/ss-v1.en.md from the repository as is. The authoritative text is the Japanese version.
SpriteStack Specification (.ss Version 1, Parts Versions 1/2)
This is a translation of the Japanese version, spec/ss-v1.md. The Japanese version is authoritative; in case of any discrepancy, the Japanese version takes precedence.
1. Scope of this specification
This specification covers a single static model. It does not include animation, bones, or divisions into parts that move independently during rendering.
The composition of parts written by AI is stored as .parts.json, and the baked model for distribution as .ss.
The baked voxels and palette are authoritative in the distribution file. The sequence of parts is the source for rebuilding the model; rebaking with a different tool is not required to produce a cell-for-cell match. The sharing site must not use the sequence of parts as input for execution or rebaking.
2. Coordinates and units
x points right, y points toward the back, and z points up. Part coordinates use an arbitrary unit of length.
cellsPerUnit is the number of cells per unit along a base edge; cellHeight is the height of a cell relative to a base edge of 1.
The base must be square. All numbers must be finite.
The indices (i,j,k) of a grid cell are nonnegative integers, each less than the number of cells along its axis.
The grid origin corresponds to bounds.min of the parts.
The front direction front is one of +x, -x, +y, and -y, with +x as the default.
3. Part description (.parts.json)
The description must be a JSON object. When passed as a string, it is UTF-8. Unknown fields are skipped according to §5.
| Field | Required | Type and rules |
|---|---|---|
| format | Required | "ss-parts" |
| formatVersion | Required | Integer 1 or 2 |
| name | Required | Model name string |
| author | Optional | Author name string |
| license | Optional | License string. SPDX identifiers are recommended (e.g. CC0-1.0, CC-BY-4.0) |
| front | Optional | Front direction from §2; default +x |
| bounds | Required | min and max, each an array of 3 numbers; max > min on each axis |
| cellHeight | Optional | Positive number; default 1 |
| bake | Required | Baking settings in the table below |
| palette | Required | Array of palette entries described below; at most 255 colors |
| parts | Required | Array of parts described below, applied in the order listed |
| overrides | Optional | Parts version 2 only. Fixed-grid overrides below |
| render | Optional | Rendering recommendations from §6 |
The sharing site accepts only CC0-1.0 and CC-BY-4.0; this is a site policy, separate from the format specification.
Palette and baking settings
| Field | Required | Type and rules |
|---|---|---|
| palette[].color | Required | sRGB #rrggbb or #rrggbbaa; hexadecimal digits are case-insensitive |
| palette[].name | Optional | Material name string. The same name must not be defined more than once |
| palette[].role | Optional | String describing the role |
| bake.cellsPerUnit | Required | Positive number |
| bake.sampling | Optional | Only "center"; center also applies when omitted |
For alpha aa, 00 is transparent and ff is opaque. A 6-digit color is treated as opaque.
A cell value of 0 means empty; n refers to palette[n-1].
Even if the palette contains translucent or transparent colors, cells with nonzero values exist in the grid.
Common part fields
| Field | Required | Type and rules |
|---|---|---|
| shape | Required | box, ellipsoid, tube, or prism |
| op | Optional | add, cut, or paint; default add |
| material | Required for add and paint | Material name or integer from 1 to the number of palette colors. Ignored for cut, with a warning |
| mirror | Optional | Array of x and y; the presence of each axis specifies reflection |
| name | Optional | Part name string |
Parts must be applied in the order listed. add sets cells inside the part to material, cut empties them, and paint changes only the color of nonempty cells. mirror applies copies with the signs of the specified axis coordinates reversed, immediately after the original, using the same op. Specifying both x and y produces 4 instances including the original. Repeating the same axis does not add more copies.
Shape fields and inside tests
The boundary must be included in the inside region.
| shape | Shape-specific fields | Inside test |
|---|---|---|
| box | center: 3 numbers; size: 3 positive numbers | abs(p-center) <= size/2 on each axis |
| ellipsoid | center: 3 numbers; radii: 3 positive numbers | Σ((p-center)/radii)^2 <= 1 |
| tube | points: array of [x,y,z,r] (at least 2 points, r > 0); caps: optional round or flat |
See below |
| prism | z: [z0,z1] (z0 < z1); bottom: array of [x,y] (at least 3 points); top: optional array with the same number of points |
See below |
tube tests each pair of adjacent points. Let t be the projection parameter on the line segment. Clamp t to the range 0 to 1,
compute r = r0 + (r1-r0)*t, and consider the point inside if its distance from the projected point is at most r.
caps defaults to round. For flat, exclude points with unclamped t < 0 on the first segment
and unclamped t > 1 on the last segment from that segment’s test.
For a segment whose two points have the same position, use t=0 and test against a sphere with the radius of the first point.
For prism, within z0 <= p.z <= z1,
use the polygon formed by linearly interpolating corresponding points of bottom and top with t=(p.z-z0)/(z1-z0).
If top is omitted, it is the same as bottom. Include edges and vertices; otherwise use the even-odd rule to determine whether a point is inside.
Self-intersecting polygons also follow the even-odd rule.
Conversion to a grid
Let cpu be cellsPerUnit. Compute the cell counts as follows.
- w = ceil((max.x - min.x) * cpu - 1e-9)
- d = ceil((max.y - min.y) * cpu - 1e-9)
- h = ceil((max.z - min.z) * cpu / cellHeight - 1e-9)
The center of cell (i,j,k) is
min + ((i+0.5)/cpu, (j+0.5)/cpu, (k+0.5)*cellHeight/cpu).
center uses only this point to test whether the cell is inside a part. Cells intersected only at their edges must not be filled.
The grid dimensions must be checked against the limits in §5 before allocating grid memory.
The reference implementation tests only cells within the part’s bounding box. Anything outside the grid is clipped.
A part for which none of the bounding boxes, including those of its copies, overlap bounds produces a warning.
After baking all parts and applying the overrides below, an entirely empty result must produce empty_model.
Fixed-grid overrides (parts version 2)
Parts version 2 may contain overrides. Omitting it produces the same result as version 1.
In version 1, overrides produces invalid_value (/overrides), rather than being skipped as unknown.
| Field | Required | Type and rules |
|---|---|---|
| overrides.basis | Required | Grid basis object described below |
| overrides.basis.bounds | Required | min and max, each containing three finite numbers |
| overrides.basis.cellsPerUnit | Required | Finite number equal to the current bake.cellsPerUnit |
| overrides.basis.cellHeight | Required | Finite number equal to the effective current cellHeight (1 when omitted) |
| overrides.cells | Required | Array; may be empty. At most min(w*d*h, 262144) entries |
| overrides.cells[].at | Required | Three nonnegative integers [i,j,k], each less than the current grid size on its axis |
| overrides.cells[].material | Required | 0 (empty), an integer from 1 through the palette length, or a unique existing material name. Null, negative numbers, and fractions are invalid |
basis records bounds min/max, cellsPerUnit, and effective cellHeight when painting starts.
Every value must numerically equal the current value; otherwise return override_basis_mismatch (/overrides/basis) before baking and list the differing fields in message.
There is no tolerance; -0 equals 0. Changing only bounds.max also mismatches. Check the basis even with zero cells.
Do not automatically change the basis, move, resample, or truncate overrides. Front and display rotation do not affect the basis.
at contains cell indices relative to bounds.min, not world coordinates. Stored indices start at zero; the displayed height is k+1.
After all operations and mirrors of all parts, independently replace each specified cell. Overrides can occupy empty cells.
Material 0 empties a cell, while transparent colors remain distinct from empty. Preserve even overrides with the same material as the underlying cell as editing intent.
Overrides stay at fixed coordinates when parts change, move, are deleted, or reordered. Removing an override means restoring the parts’ result.
Allow one entry per coordinate. Second and later duplicates produce duplicate_override; array order never gives precedence.
Readers accept any ordering; editors save in ascending k, then j, then i order.
Validate grid size and entry count before allocating grids or working arrays. The 16 MiB string and grid limits also apply.
The entry-count limit applies to object input too. Reject the whole input on overflow without partial application.
Empty parts are valid if at least one cell exists after overrides. If all cells are zero afterwards, return empty_model (the existing /parts path).
The following shows additions only, not a complete document.
{ "formatVersion": 2, "overrides": { "basis": { "bounds": { "min": [0, 0, 0], "max": [50, 32, 36] }, "cellsPerUnit": 1, "cellHeight": 1 }, "cells": [ { "at": [10, 4, 21], "material": "明るい金属" }, { "at": [11, 4, 21], "material": 0 } ] }}Palette renaming, deletion, and renumbering update both parts and override references in the same source transaction, leaving material 0 unchanged. Keep the full source when passing overrides to AI; do not move or delete overrides or revert to version 1 without an explicit request.
Minimal example
{ "format": "ss-parts", "formatVersion": 1, "name": "box", "bounds": { "min": [0, 0, 0], "max": [4, 4, 4] }, "bake": { "cellsPerUnit": 1 }, "palette": [{ "color": "#b3a340", "name": "shell" }], "parts": [ { "shape": "box", "center": [2, 2, 2], "size": [2, 2, 2], "material": "shell" } ]}4. Model for distribution (.ss)
Store the following entries in a ZIP archive under these names. Duplicate occurrences of these names produce invalid_container. Readers must not use names within the ZIP archive as filesystem write destinations.
| Name | Required | Contents |
|---|---|---|
| model.json | Required | UTF-8 JSON containing information and the palette |
| voxels.bin | Required | Grid with 1 byte per cell |
| source.parts.json | Optional | Original part description. When reading, retain it as a UTF-8 string without executing, rebaking, or validating it as parts |
The .ss formatVersion remains 1. voxels.bin contains the grid with overrides already applied.
The source parts version is independent; version 2 source can be included verbatim and must not be executed for rendering.
model.json fields
| Field | Required | Type and rules |
|---|---|---|
| format | Required | "ss" |
| formatVersion | Required | Integer 1 |
| name | Required | Model name string |
| author | Optional | Author name string |
| license | Optional | License string. SPDX identifiers are recommended (e.g. CC0-1.0, CC-BY-4.0) |
| generator | Optional | name and version are both required strings |
| front | Optional | Front direction from §2; default +x |
| grid | Required | size and cellHeight as described below |
| grid.size | Required | 3 positive integers [w,d,h], within the limits in §5 |
| grid.cellHeight | Optional | Positive number; default 1 |
| pivot | Optional | 3 numbers in grid cell units; default [w/2,d/2,0] |
| palette | Required | Palette from §3 |
| render | Optional | Rendering recommendations from §6 |
| bake | Optional | cellsPerUnit (positive number) and sampling ("center") are required |
pivot is the center of rotation and ground contact point relative to the grid origin.
The reference implementation’s modelFromParts always constructs [w/2,d/2,0] from the cell counts after ceil.
The absolute part coordinates or the width of bounds before rounding must not be used as pivot.
generator may record the name and version of the tool that created the model. The reference implementation records
spst and the package version.
{ "format": "ss", "formatVersion": 1, "name": "hercules", "generator": { "name": "spst", "version": "0.1.0" }, "front": "+x", "grid": { "size": [200, 120, 80], "cellHeight": 1 }, "pivot": [100, 60, 0], "palette": [{ "color": "#242521", "name": "black" }], "bake": { "cellsPerUnit": 2, "sampling": "center" }}voxels.bin layout
Cell (i,j,k) must be stored at byte offset i + w * (j + d*k).
The length is exactly wdh bytes. 0 means empty; n refers to palette[n-1].
If any value exceeds the number of palette colors, produce voxel_out_of_palette.
Reading an empty distribution grid is allowed, but baking from parts performs the empty_model check in §3.
5. Reader rules
For supported versions, unknown fields must produce an unknown_key warning regardless of object depth and must be skipped.
Preserve the original source, but remove unknown fields from the checked doc.
If the parts formatVersion is greater than 2, or the distribution formatVersion is greater than 1, return unsupported_version (/formatVersion) and stop reading.
Other unsupported values or types produce invalid_value. Old readers supporting only parts version 1 reject version 2.
| Format and version | Known fields |
|---|---|
| Parts version 1 | Top-level fields in §3; overrides is known but forbidden (invalid_value) |
| Parts version 2 | All fields in §3, including nested fields in the overrides table |
| Distribution version 1 | Fields in §4 |
The following limits must not be exceeded. A MiB is 1,048,576 bytes.
| Target | Limit | When exceeded |
|---|---|---|
| Palette | 255 colors | palette_too_large |
| Each grid edge | 1024 cells | grid_too_large |
| Entire grid | 16,777,216 cells | grid_too_large |
| Override entries | min(wdh, 262144) | overrides_too_large (/overrides/cells) |
| Part JSON string | 16 MiB in UTF-8 | invalid_value, with an empty string for path |
| .ss ZIP input | 64 MiB | invalid_container |
| Uncompressed size of model.json | 1 MiB | invalid_container |
| Uncompressed size of source.parts.json | 16 MiB | invalid_container |
| Uncompressed size of voxels.bin | 16,777,216 bytes | invalid_container |
For known ZIP entries, check the declared size before decompression; entries exceeding the limit must not be decompressed.
For the stored (uncompressed) method, also compare the actual stored size with the limit.
Skip unknown ZIP names without decompressing them, and return an unknown_key warning
with the JSON Pointer /zip/<name>. In the name, encode / as ~1 and ~ as ~0.
The CLI must check the file size in advance and must read no more than the limit plus 1 byte.
The reference implementation reads regular files and also reports growth during reading as an error.
The reference implementation’s checkParts accepts a string or an unknown value. The string size limit is applied before JSON parsing. The string byte count check does not apply to objects passed directly from a program. Type and semantic checks apply to both.
6. Rendering recommendations
| Field | Type and meaning |
|---|---|
| render.sliceSpacing | Finite number at least 0. Display spacing between slices, with one cell’s base edge as 1 |
| render.initialAngleDeg | Finite number. Initial display angle in degrees |
| render.background | Background color in #rrggbb or #rrggbbaa |
These are optional, and readers may override them. cellHeight, which determines the shape of a cell, and sliceSpacing, which specifies display spacing, must not be combined into a single field. The overall defaults for rendering recommendations are an open question in §7 of the project specification.
Example of reader rendering (not required)
The reference implementation’s render and turntable accept finish: "flat" | "pixel".
The library defaults to flat; the CLI and the viewer’s slice display default to pixel.
This is a tool option, not a file field or a requirement for other readers.
flat stacks slices on a transparent background using the following procedure and preserves palette colors.
- Let the slice spacing s be
opts.sliceSpacing ?? model.render?.sliceSpacing ?? model.cellHeight. - Let R be the maximum distance from pivot to the 4 base corners. Set the width to
W = 2 * ceil(R * scale)and the height toH = W + ceil((h - 1) * s * scale). - The center of slice k is
cx = W / 2,cy = H - W / 2 - k * s * scale. Stack upward from slice 0; the RGBA of nonempty cells in later slices overwrites earlier slices. - From pixel (sx, sy), compute
dx = (sx + 0.5 - cx) / scaleanddy = (sy + 0.5 - cy) / scale. Add pivot’s x and y tox = cos θ * dx + sin θ * dyandy = -sin θ * dx + cos θ * dy, respectively, then apply floor to obtain (i, j) and read that cell. At θ=0, +x points right and +y points down; angles increase clockwise when viewed from above. - The color is the RGBA of
palette[v - 1]. Empty cells are not drawn, and the background is transparent. - turntable arranges images with
angleDeg = 360 * n / framesside by side.
pixel renders at native resolution and then applies integer nearest-neighbor enlargement.
pitchDeg is the viewing angle above the horizon: a finite number from 14 to 66, default 30.
Providing pitchDeg with flat, or an unknown finish, raises RangeError.
-
The reference
renderimplementation accepts display-onlypixeloptions:sliceLifts, an array with one entry per slice specifying upward displacement in unscaled pixels (0 means landed,Infinityhides a slice), andheadroom, transparent top padding in unscaled pixels (finite and nonnegative, rounded up, default 0). Negative values,NaN, mismatched array length, or either option supplied toflatorturntableraiseRangeError. Only landed slices cast shadows. Lifted slices appear in front of landed slices; among lifted slices, higher slice indices appear in front. Padding counts toward the pixel limit. These are reference implementation tools, not reader requirements or.ssfields. -
With p as the pitch in radians, compress the ground vertically by
sin p. Slice spacing isopts.sliceSpacing ?? model.render?.sliceSpacing ?? model.cellHeight * cos(p). Sample sub-slices withinmin(slice spacing, cellHeight * cos(p)); preserve explicitly requested gaps. -
Derive the screen-center phase from the fractional components of pivot so symmetric models align at opposite angles.
-
Average neighboring surface normals derived from occupancy, then select four color bands using camera-fixed lighting. Shift dark bands toward cool colors and light bands toward warm colors in Oklab. Preserve the original-color band and alpha.
-
Darken large depth discontinuities without drawing an outline outside the model. Behind the model, place a black ground shadow at 25% opacity, displaced horizontally by 0.2 cells per unit height toward the screen’s lower right.
-
Keep dimensions independent of rotation and include the shadow and a transparent 1 px border. Enforce the pixel limit after enlargement, including the full turntable image.
The CLI accepts --finish pixel|flat and --pitch <degrees> to override these defaults.
In the reference implementation, scale is an integer from 1 to 16, frames is an integer from 1 to 64, and angleDeg is a finite number. If the entire image (the full side-by-side image for turntable) exceeds 16,777,216 pixels, it is not rendered and a RangeError is raised. For violations of these argument constraints or image limits, the CLI displays usage and exits with code 2.
7. Validation code list
An Issue has code, path, and message. path is a JSON Pointer, and message is in Japanese. If there is an error, ok is false; if there are only warnings, processing may continue.
| code | Severity | When |
|---|---|---|
invalid_json |
error | Cannot be read as JSON |
missing_field |
error | A required field is missing |
invalid_value |
error | Incorrect type, range, or choice (such as a nonfinite number or negative size) |
unknown_key |
warning | A field not in the specification (skipped; can help identify a typo) |
unsupported_version |
error | Parts formatVersion is greater than 2, or distribution version is greater than 1 |
unknown_material |
error | The material name or number is not in the palette. If candidates with similar names exist, include them in message |
duplicate_material_name |
error | Duplicate name in the palette |
palette_too_large |
error | The palette exceeds 255 colors |
degenerate_shape |
error | Size or radius is at most 0, tube has fewer than 2 points, prism has reversed or equal z endpoints, or a polygon has fewer than 3 points |
polygon_mismatch |
error | The numbers of points in prism’s top and bottom differ |
missing_material |
error | add or paint lacks material |
material_on_cut |
warning | cut has material (unused) |
grid_too_large |
error | The grid exceeds the limits (checked before baking, without allocating memory) |
part_outside_bounds |
warning | The part’s bounding box does not overlap bounds |
override_basis_mismatch |
error | Basis mismatch; path /overrides/basis |
override_outside_grid |
error | Out-of-grid coordinate; path /overrides/cells/N/at |
duplicate_override |
error | Second and later entries at the same coordinate; path /overrides/cells/N/at |
overrides_too_large |
error | Too many override entries; path /overrides/cells |
overrides_present |
warning | At least one override; path /overrides. A reminder of fixed coordinates after part changes, not detection of misalignment |
empty_model |
error | All cells are zero after overrides; path /parts |
invalid_container |
error | .ss is not a ZIP archive, model.json or voxels.bin is missing, or the length does not match the grid |
voxel_out_of_palette |
error | voxels.bin contains a value exceeding the number of palette colors |
| The invalid_container code above also covers size limit violations from §5, duplicate known ZIP entries, and invalid UTF-8 in source. | ||
| unknown_material for parts includes candidates whose names have an edit distance of at most 2 in message. | ||
Missing override material references also produce unknown_material (/overrides/cells/N/material). |
||
| Overrides in version 1, invalid coordinate types, null, negative materials, and invalid basis types produce invalid_value at the relevant path. |
8. Versioning
Versions are managed per format. Parts version 2 requires interpreting overrides.
Increase the parts version so unsupported readers cannot skip fields that change the result.
The distribution grid retains the same meaning, so .ss stays at version 1.
Extensions that only add optional fields in a way that allows readers to skip unknown fields may be made without increasing the version. Changing the meaning of an existing field requires increasing formatVersion. When extending an existing field’s choices to allow values unknown to readers, also consider compatibility with older readers. The license for the specification document, the English version, and the scope of conformance tests are decided in §7 of the project specification.
History of the format names
Until 2026-11-28, the reference implementation wrote sss and sss-parts in format, and
@simple-sprite-stack/sss in the generator name. Readers do not have to read the old values (the reference implementation does not read them since 2026-11-29).
Only the names changed and the meaning of the fields did not, so formatVersion stays 1.