Introduction
A .vox file is the project format of
MagicaVoxel, a voxel editor and renderer by
ephtracy. It holds one or more voxel models whose voxels are indexes into a 256 colour
palette, and in newer files a scene graph, layers, materials and camera settings.
Many other voxel tools and game engine importers read it.
A file begins with the four bytes VOX (with a space) and a version
number.
Structure
All integers are little-endian. After the 8-byte header the file is a tree of chunks,
in the manner of RIFF: one MAIN chunk whose children are all the
others.
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 0 | 4 | magic | VOX : bytes 56 4F 58 20 |
| 4 | 4 | version | 150 or 200 |
| 8 | … | MAIN | The root chunk |
Chunk
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 0 | 4 | id | Four characters |
| 4 | 4 | N | Bytes of content |
| 8 | 4 | M | Bytes of child chunks |
| 12 | N | content | Depends on the id |
| 12 + N | M | children | Further chunks |
MAIN has no content of its own. A reader can pass over a chunk it does
not know by its sizes.
Chunk list
| Id | Holds | How many |
|---|---|---|
PACK | Number of models | 0 or 1 |
SIZE | Size of a model | One per model |
XYZI | Voxels of a model | One after each SIZE |
RGBA | Palette | 0 or 1 |
IMAP | Order of colours in the editor’s palette | 0 or 1 |
NOTE | Palette colour names | 0 or 1 |
nTRN | Scene transform node | Any number |
nGRP | Scene group node | Any number |
nSHP | Scene shape node | Any number |
LAYR | Layer | Any number |
MATL | Material of one colour | Any number |
MATT | Old material chunk, replaced by MATL | Any number |
rOBJ | Render settings | Any number |
rCAM | Saved camera | Any number |
META | File settings: animation range | 0 or 1 |
Models and voxels
Each model is a SIZE chunk followed by an XYZI chunk. The
first pair is model 0, the next model 1, and so on. PACK, with a single
integer giving the number of pairs, appears in older animation files; without it the
pairs are simply counted.
SIZE
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 0 | 4 | x | Width in voxels |
| 4 | 4 | y | Depth in voxels |
| 8 | 4 | z | Height in voxels; z is the up direction (gravity) |
XYZI
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 0 | 4 | numVoxels | Number of filled voxels |
| 4 | 4 × numVoxels | voxels | Four bytes each: x, y, z, colour index |
Only filled voxels are listed. Colour indexes run from 1 to 255; 0 stands for empty space. Coordinates are single bytes, and the writer in the opengametools reader limits a model to 256 voxels along each axis.
Palette
RGBA holds 256 entries of four bytes, red, green, blue, alpha. The
numbering is shifted by one: entry i of the chunk, for i from 0
to 254, is the colour of voxel index i + 1. The last entry is not
used by any voxel.
Default palette
A file without RGBA uses a fixed palette, published as 256 words of the
form 0xAABBGGRR. Index 0 is zero and every other entry is opaque. The
table follows a regular pattern:
| Index | Colours |
|---|---|
| 1 to 215 | A cube of six levels per channel, FF CC 99 66 33 00. With n = index − 1: red is level n ÷ 36, green level (n ÷ 6) mod 6, blue level n mod 6 (whole-number division). Black, which would be last, is left out |
| 216 to 225 | Red ramp: EE DD BB AA 88 77 55 44 22 11, other channels 0 |
| 226 to 235 | Green ramp, same ten levels |
| 236 to 245 | Blue ramp, same ten levels |
| 246 to 255 | Grey ramp, all three channels at the same ten levels |
IMAP
When colours have been rearranged in the editor’s palette window, the voxels keep
their indexes and an IMAP chunk records the displayed order. Its content
is 256 bytes. Byte k is the voxel colour index shown at editor position
k + 1. A program that only draws the model can ignore the chunk;
one that cares about the numbering the artist sees reorders palette, materials and
voxel indexes with it.
NOTE
An integer count followed by that many strings: names attached to the palette.
Strings and dictionaries
The scene, material and render chunks use two compound types.
| Type | Layout |
|---|---|
| STRING | int32 length, then that many bytes, with no terminating zero |
| DICT | int32 number of pairs, then for each pair a STRING key and a STRING value |
All values in a dictionary are text, including numbers. Several numbers in one value are separated by spaces. A key that is absent leaves its default.
Scene graph
Three node chunks place models in a world. Nodes are numbered, and node 0 is the root. A transform node has exactly one child, which is a group node or a shape node; a group node has transform nodes as children; a shape node refers to models. Nodes can name children that appear later in the file.
nTRN
└ nGRP
├ nTRN ─ nGRP ─ …
└ nTRN ─ nSHP ─ model
nTRN: transform node
| Field | Type | Meaning |
|---|---|---|
| node id | int32 | |
| attributes | DICT | _name; _hidden (0 or 1); _loop (0 or 1, animation repeats); _frm_r and _frm_t, an optional base rotation and translation |
| child id | int32 | The node it moves |
| reserved | int32 | −1 |
| layer id | int32 | Layer the node belongs to |
| frames | int32 | Number of frames, at least 1 |
| frame attributes | DICT × frames | _r rotation byte written as a decimal number; _t translation, three integers x y z; _f frame number |
An absent _r or _t means no rotation or no movement. Where
a base pose is present, the opengametools reader uses it as the node’s still
transform; otherwise it uses the first frame. Between key frames that reader keeps the
rotation of the earlier frame and interpolates the translation linearly, rounding
towards zero.
nGRP: group node
| Field | Type | Meaning |
|---|---|---|
| node id | int32 | |
| attributes | DICT | |
| children | int32 | Number of child nodes |
| child ids | int32 × children |
nSHP: shape node
| Field | Type | Meaning |
|---|---|---|
| node id | int32 | |
| attributes | DICT | _loop |
| models | int32 | Number of model entries, at least 1 |
| entries | (int32, DICT) × models | Model number, then attributes: _f, the frame number at which that model is shown |
Placement
Transforms apply down the tree. A model turns and moves about its pivot, which is the voxel corner at (⌊x÷2⌋, ⌊y÷2⌋, ⌊z÷2⌋) of its size: subtract the pivot from the voxel coordinates before applying the transforms.
Rotation byte
A rotation is a 3 × 3 matrix that permutes and mirrors the axes, so each row has one non-zero entry, 1 or −1. It is stored row by row in one byte.
| Bits | Meaning |
|---|---|
| 0–1 | Column (0 to 2) of the non-zero entry in row 1 |
| 2–3 | Column of the non-zero entry in row 2 |
| 4 | Sign of row 1: 1 is negative |
| 5 | Sign of row 2 |
| 6 | Sign of row 3 |
Row 3 uses the column left over. The identity matrix is the value 4. The published example
0 1 0
0 0 -1
-1 0 0
is (1 << 0) | (2 << 2) | (0 << 4) | (1 << 5) | (1 << 6),
which is 105.
Layers
| Field of LAYR | Type | Meaning |
|---|---|---|
| layer id | int32 | Referred to by transform nodes |
| attributes | DICT | _name; _hidden (0 or 1); _color, three numbers r g b |
| reserved | int32 | −1 |
Materials
MATL is an int32 material id followed by a DICT. The id is the colour
index the material belongs to; the opengametools reader keeps only its low byte, so
that 256 falls on 0.
| Key | Value |
|---|---|
_type | _diffuse, _metal, _glass, _emit, _blend or _media |
_weight | Number from 0 to 1 |
_rough | Roughness |
_spec | Specular |
_ior | Index of refraction |
_ri | Refractive index; read as _ior = value − 1 |
_att | Attenuation |
_flux | Power of an emitting material; the editor offers whole numbers 0 to 4 |
_plastic | Plastic flag |
_metal | Metalness, 0 to 1 |
_emit | Emission, 0 to 1 |
_ldr | “Low dynamic range” share of an emitting material, 0 to 1 |
_trans | Transparency, 0 to 1 |
_alpha | An older key that MagicaVoxel 0.99.7.2 still reads |
_d | Density of the medium; the editor’s slider runs from 0 to 0.1, and larger values can be typed |
_sp | Specular of a metal material; the slider runs from 1 to 2 and values up to 3 can be typed (reader default 1) |
_g | Phase of the medium, −0.9 to 0.9 |
_media | An older form of _media_type |
_media_type | _absorb (default), _scatter, _emit or _sss |
The editor of MagicaVoxel 0.99.7.2 shows _ri as a refractive index from 1 to 3.
Where a material holds the older _weight, that program converts it by type:
- emit:
_emittakes the weight; - metal:
_metaltakes the weight and_spis_spec+ 1; - glass:
_transtakes the weight, the medium is absorbing and_dis −ln(1 − 0.4 ×_att), held between 0 and 0.1; - media: the medium is scattering and
_dcomes from the weight by the same formula; _plastic: becomes a metal material with_metal0 and_ri=_spec_p+ 1.
The older keys _g0, _g1 and _gw combine into
_g = _g0 + (_g1 − _g0) × _gw.
MATT, the older material chunk
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 0 | 4 | id | Colour index, 1 to 255 |
| 4 | 4 | type | 0 diffuse, 1 metal, 2 glass, 3 emissive |
| 8 | 4 | weight | Float. Diffuse 1.0; the others above 0 up to 1, blending towards that material |
| 12 | 4 | properties | Bit set. Bit 0 plastic, 1 roughness, 2 specular, 3 index of refraction, 4 attenuation, 5 power, 6 glow, 7 total power flag, which has no value |
| 16 | 4 × n | values | One float for each set bit 0 to 6, lowest bit first, normalised from 0 to 1 (plastic is 0 or 1) |
The order is the one in which the reader of MagicaVoxel 0.98.2 takes the values. Version
0.99.7.2 reads MATL and not MATT.
Cameras, render settings and file settings
rCAM
An int32 camera id and a DICT.
| Key | Value |
|---|---|
_mode | pers perspective, free, pano panorama, iso isometric or orth orthographic |
_focus | Three numbers: the point looked at |
_angle | Three numbers in degrees: pitch (−180 to 180), yaw (0 to 360) and roll (0 to 360) |
_radius | Distance from the point looked at; in the orthographic and isometric modes it also affects the size of the view |
_frustum | Height of the near plane: tan(field of view ÷ 2) in perspective, a height in voxels in the orthographic mode |
_fov | Vertical field of view in degrees, whole number |
The units are those given in the comments of ogt_vox.h.
rOBJ
A single DICT of rendering attributes. When _type is _inf it
describes the sun:
| Key | Meaning |
|---|---|
_i | Intensity (reader default 0.7) |
_area | Area (default 0.7) |
_angle | Two angles (default 50 50) |
_k | Colour, r g b (default white) |
_disk | Whether the sun disk is shown (default 0) |
rOBJ types in a saved file
The other kinds of rOBJ are in no published description. This table lists every
rOBJ dictionary of axes.vox, a version 200 test file of the
dot_vox library, with the keys and the values stored
there. All values are text. MagicaVoxel 0.99.7.2 writes the same groups and keys, numbers as decimal
text, colours as three whole numbers and pairs as two numbers.
_type | Keys and stored values |
|---|---|
_inf (sun) | _i 0.7, _k 255 255 255, _angle 50 50, _area 0.07, _disk 0 |
_uni | _i 0.7, _k 255 255 255 |
_ibl | _path HDR_041_Path_Env.hdr (the name of a separate environment image), _i 1, _angle 0 0 |
_env | _mode 0 |
_bounce | _diffuse 2, _specular 5, _scatter 5, _energy 3 |
_atm | _ray_d 0.4, _ray_k 45 104 255, _mie_d 0.4, _mie_k 255 255 255, _mie_g 0.85, _o3_d 0, _o3_k 105 255 110 |
_fog_uni | _d 0, _k 255 255 255, _g 0 |
_lens | _proj 0, _fov 45, _aperture 0.25, _blade_n 0, _blade_r 0 |
_film | _expo 1, _vig 0, _aces 1, _gam 2.2 |
_bloom | _mix 0.5, _scale 0, _aspect 0, _threshold 1 |
_ground | _color 80 80 80, _hor 0.1 |
_bg | _color 0 0 0 |
_edge | _color 0 0 0, _width 0.2 |
_grid | _color 0 0 0, _spacing 1, _width 0.02, _display 0 |
_setting | _ground 1, _grid 0, _edge 0, _bg_c 0, _bg_a 0, _scale 1 1 1, _cell 1 |
The editor’s lighting panel in that version gives these meanings and ranges:
_inf, the sun:_angleis pitch (−90 to 90) and yaw (0 to 360) in degrees,_ithe intensity as a fraction (the panel shows per cent and accepts up to 500),_kthe colour,_areathe size of the sun and_diska switch.ogt_vox.hgives an area of 1.0 as about 43.5 degrees._uni, a uniform sky: intensity and colour._atm, an atmospheric sky: density (_d) and colour (_k) of Rayleigh scattering (_ray), Mie scattering (_mie) and ozone (_o3);_mie_gis the Mie phase, −0.9 to 0.9._ibl, an image-based sky: the HDR image_pathnames, its intensity and its rotation, 0 to 360 degrees, the second number of_angle. The program also reads_rot, a fraction of a turn._fog_uni, uniform fog: density_d(slider 0 to 10, up to 5000 typed), colour_kand phase_g(−0.9 to 0.9)._setting: the program also reads_swand_aa, which it does not write.
The panel layouts in the release of 0.99.7.2 (the .ui files in config/ui)
give these ranges for the other groups. The keys are matched to the controls by name and stored
value.
_env,_mode: 0 uniform sky, 1 atmospheric scattering, 2 image-based lighting. Sun, sky and image intensities run from 0 to 500 per cent._bounce:_diffusedepth 0 to 15,_specular(reflection and refraction) depth 5 to 15,_scatterdepth 5 to 15,_energy1 to 5000, where radiance is clamped._lens:_proj0 perspective, 1 stereographic, 2 panorama (equirectangular);_fov1 to 360;_aperture0 to 1;_blade_ndiaphragm blades 0 to 8,_blade_rtheir rotation −180 to 180._film:_expoexposure (slider 1 to 16, 0 to 30 typed),_vigvignette 0 to 1,_acesa switch for ACES filmic tone mapping,_gamgamma 1 to 5._bloom:_mix0 to 1,_scale(size) 0 to 1,_aspect0 to 1,_threshold0 to 100._ground:_color, and_horthe horizon, a stored fraction of the panel’s 0 to 100 per cent._bg:_color._edge:_color,_width0.01 to 5._grid:_color,_spacing1 to 1024,_width0.01 to 1,_displaya switch for showing it on the ground only._setting: switches_ground,_grid,_edge,_sw(shadows),_aa(anti-aliasing),_bg_c(show the background colour) and_bg_a(transparent background);_scalethe voxel scale (x 0 to 10, y and z 0 to 100) and_cellthe cell size, 0 to 1.
The ten rCAM chunks of the same file all hold _fov 45 and
_frustum 0.414214, which is the tangent of half that angle.
Render chunks of earlier files
Another dot_vox test file, metal-material.vox (version 150), has no rOBJ. Its
render settings are in five other chunks after the palette, each a single DICT. These are in no published
description either; the keys below are the ones in that file. The type names here have no leading
underscore.
| Chunk | Keys and stored values |
|---|---|
rLIT | _type inf, _I 0.6, _color 255 255 255, _angle 50 50, _area 0.07 |
rLIT | _type uni, _I 0.7, _color 255 255 255 |
rAIR | _type fog, _density 0.2, _color 255 255 255, _scatter 0 |
rLEN | _fov 45, _dof 0.25, _exp 0, _vig 0, _sg 0, _gam 2.2 |
POST | _type bloom, _mix 0.5, _scale 1, _threshold 1 |
rDIS | _gd_color 80 80 80, _bg_color 0 0 0, _edge_color 0 0 0 |
MagicaVoxel 0.99.1 alpha reads the same five chunks with these keys: for rLIT the types
inf (_I, _color, _angle, _area) and
uni (_I, _color); for rAIR _density,
_color and _scatter; for rLEN _fov,
_dof, _exp, _vig, _sg and _gam; for
POST the types bloom (_mix, _scale,
_threshold) and aces; and for rDIS
_ground_color (where the test file has _gd_color),
_bg_color and _edge_color.
The same version also reads rOBJ chunks, with groups of its own: _inf
(_i, _k, _angle, _area), _uni
(_i, _k), _rayleigh (_d, _k),
_mie (_d, _k, _g), _fog
(_d, _k, _enable), _len (_fov,
_dof, _exp, _vig, _sg, _blade_n,
_blade_r, _gam), _ground and _bg
(_color, _enable), _edge (_width,
_color, _enable), _grid (_spacing,
_width, _color, _display, _enable),
_bloom (_mix, _scale, _aspect,
_threshold, _enable) and _aces.
META
A single DICT. _anim_range holds two numbers, the first and last frame of
the animation. The opengametools writer adds the chunk to version 200 files.
Worked example
A 64-byte file with one 2 × 2 × 2 model, one voxel and no palette.
| Offset | Bytes | Meaning |
|---|---|---|
| 0 | 56 4F 58 20 96 00 00 00 | VOX , version 150 |
| 8 | 4D 41 49 4E 00 00 00 00 2C 00 00 00 | MAIN, no content, 44 bytes of children |
| 20 | 53 49 5A 45 0C 00 00 00 00 00 00 00 | SIZE, 12 bytes |
| 32 | 02 00 00 00 02 00 00 00 02 00 00 00 | 2, 2, 2 |
| 44 | 58 59 5A 49 08 00 00 00 00 00 00 00 | XYZI, 8 bytes |
| 56 | 01 00 00 00 | One voxel |
| 60 | 01 00 00 4F | x 1, y 0, z 0, colour 79 |
Colour 79 of the default palette is red 99, green CC, blue
FF.
Divergence from the specification
- The published description gives the version as 150. The opengametools reader accepts 150 and 200 and no other value. Its documentation says that where scene instances overlap, the lower instance numbers win when merging a file of version 200 (“or perhaps higher”), and the higher numbers win below 200.
- For
IMAPthe description states a size of 256 and lists 256 entries as int32. The reader requires a content of 256 bytes, one byte per entry. - The keys
_loop,_frm_r,_frm_t,_color, the material types_blendand_media, most later material keys, the sun settings and theMETAchunk are not in the published description; they are taken from the reader. - The render groups and keys, the ranges of the material keys and the conversion of older material keys are in neither; they are taken from MagicaVoxel itself.
In the explorer
A dropped .vox file that starts VOX opens as a MagicaVoxel model;
other .vox files are taken as Dialogic audio.
- 3D view: the scene, with shapes placed by the transform and group nodes, or model 0 when there is no scene graph. The exposed faces of the voxels are drawn in the palette’s colours, from the file or the default one. Hidden nodes and layers are left out. A view holds 250,000 voxels; the rest of a larger scene is in further parts, however many shapes and nodes it has. A link that makes a node contain itself is not followed.
- Materials:
MATLandMATTare drawn approximately: metal and blend with a highlight, glass, blend and media as see-through, emitting voxels in their own colour, brightened by their power. - Cameras and light: each
rCAMis a view preset, perspective or orthographic; yaw 0 is taken to look from the file’s +y side. The sun and uniform sky ofrOBJorrLITlight the model (a “File lighting” switch), and the background colour, ground and grid follow the render settings. Atmospheric and image skies appear as an even grey light. - Models and animation: every model has its own view and voxel table. The scene of
an animated file plays at 10 frames a second (the file stores no rate), with
_loopapplied, and a table of frames gives the scene at every frame from the first to the last that the file names. An animated scene has parts enough for its fullest frame, so a frame with more voxels than the still scene plays on into the further parts. - Tables: nodes with all their attributes and frames, layers, materials (
MATTwith its type and named property values), render, camera and file settings, the palette and its picture,IMAP,NOTEand every chunk. - Checks: chunks cut off or too short, unlisted chunks, voxel counts and
coordinates that do not fit, missing nodes and models, cycles, repeated node numbers, bad rotation
bytes and a wrong
PACKcount.
Not described
Known, not yet covered
- Viewer: reflections, refraction, shadows, light cast by emitting voxels and scattering inside media.
- Viewer: camera roll, the stereographic and panorama projections, depth of field, film settings and bloom.
- Viewer: voxel edges, grid spacing and width, the horizon, voxel scale and cell size, fog, and the atmospheric and image skies.
Unknown
- Reference: the direction from which an
rCAMcamera with yaw 0 looks, and which key stores the voxel shape. - Reference: the value types of
_scatterand_sgand the ranges of the keys of the earlier render chunks. - Reference: what MagicaVoxel does with the older material key
_alpha. - Reference: what separates version 200 from version 150 beyond the number, the added chunk and the order in which overlapping instances are merged.
Also used for
- Dialogic VOX ADPCM audio – Telephone recordings in OKI ADPCM, 4 bits a sample, no header.
Links
Software
- MagicaVoxel – the voxel editor and renderer that defines the format (Windows, macOS)
- Goxel – open source voxel editor that handles VOX files (Windows, macOS, Linux, web)
Developers
- opengametools –
ogt_vox.h, a reader and writer (C++)
Reference
- MagicaVoxel .vox file format – the author’s description of the chunks and default palette
- VOX format extensions – scene graph, materials, layers and cameras
- First version of the description – includes the layout of
MATT - ogt_vox.h – source for the later keys,
IMAPandMETA - dot_vox test files –
axes.voxandmetal-material.vox, whose render chunks are tabled above - MagicaVoxel releases – versions 0.98.2, 0.99.1 alpha and 0.99.7.2, examined for the material and render keys