Vertex positions, indices, animation keys and other bulk data live in binary buffers. glTF reaches them in three steps: a buffer is a block of bytes, a buffer view is a slice of it, and an accessor says how to read typed elements from a view. All binary data is little-endian. This page follows the Khronos glTF 2.0 specification and its JSON schemas.
Buffers and buffer views
| Object | Property | Meaning |
|---|---|---|
buffer | byteLength | required, at least 1 |
uri | a relative path or a data: URI with base64, whose media type must be application/gltf-buffer or application/octet-stream; omitted for the BIN chunk of a GLB (or when an extension supplies the data; with no data source the content is undefined). The referenced resource must be at least byteLength bytes, and only that range counts. Buffers should not exceed 253 − 1 bytes | |
bufferView | buffer | required: which buffer |
byteOffset | default 0 | |
byteLength | required, at least 1 | |
byteStride | 4 to 252, a multiple of 4: the distance between the starts of two vertex elements; no larger than byteLength; only for views holding vertex attribute data (never for other data); omitted for tightly packed data, and required when two or more vertex attribute accessors (morph targets included) share the view | |
target | a hint for the GPU buffer: 34962 vertex data (ARRAY_BUFFER), 34963 indices (ELEMENT_ARRAY_BUFFER); only allowed on views used directly by index or vertex attribute accessors, and the view must lie wholly inside its buffer (byteOffset + byteLength ≤ the buffer’s length). A view holds one kind of data: vertex attributes, indices or inverse bind matrices cannot share a view |
Accessors
| Property | Meaning |
|---|---|
bufferView | the view; when omitted the elements are all zero (or come only from sparse), and byteOffset must then be absent |
byteOffset | default 0; a multiple of the component size; the view must hold byteOffset + (count − 1) × stride + element size bytes |
componentType | required: below |
normalized | default false: whether integers stand for 0 to 1 or −1 to 1 |
count | required, at least 1: the number of elements |
type | required: below |
min, max | the smallest and largest value of each component, as many numbers as the type has components; required for POSITION and for animation sampler inputs. For integer types they must match the stored integers exactly, even when normalized is true. For floats they must match after rounding to 32-bit float. With sparse data they describe the result after replacement |
sparse | values that differ from the base (below) |
| componentType | Type | Size | Normalized value |
|---|---|---|---|
| 5120 | signed byte | 1 | max(c ÷ 127, −1) |
| 5121 | unsigned byte | 1 | c ÷ 255 |
| 5122 | signed short | 2 | max(c ÷ 32,767, −1) |
| 5123 | unsigned short | 2 | c ÷ 65,535 |
| 5125 | unsigned int | 4 | not allowed. Not to be used for any vertex attribute or morph target |
| 5126 | float | 4 | not allowed |
| type | Components |
|---|---|
SCALAR | 1 |
VEC2, VEC3, VEC4 | 2, 3, 4 |
MAT2, MAT3, MAT4 | 4, 9, 16, column by column |
Alignment
- An accessor’s offset within its view, and the view’s offset within its buffer taken together, must be a multiple of the component size.
- For a vertex attribute accessor every element must start on a 4-byte boundary:
the accessor’s offset is a multiple of four, and either the component size is a
multiple of four or the buffer view defines
byteStride(so a VEC3 of bytes, 3 bytes long, needs a stride such as 4). The stride must be at least the element size and a multiple of the component size. - Each column of a matrix starts on a 4-byte boundary: a MAT2 of bytes takes 8 bytes, a MAT3 of bytes 12 and a MAT3 of shorts 24.
Sparse accessors
sparse stores only the elements that differ from the base data (the
view, or zeros). It has three required parts: count, the number of
changed elements; indices, a bufferView,
byteOffset (default 0) and componentType (5121, 5123 or
5125), listing the changed element numbers in strictly rising order; and
values, a bufferView and byteOffset holding the
new elements, tightly packed, in the accessor’s own type. count is at
least 1 and at most the accessor’s count; every index is below the
accessor’s count; the buffer views of the indices and the values must
not define byteStride or target; the offsets must be
multiples of the index size and of the component size. Replacement happens after the
base elements are read.
Vertex attributes
| Name | Type | Components | Meaning |
|---|---|---|---|
POSITION | VEC3 | float | positions; the accessor needs min and max |
NORMAL | VEC3 | float | unit normals |
TANGENT | VEC4 | float | tangents; w is +1 or −1 and gives the bitangent’s direction |
TEXCOORD_n | VEC2 | float, or normalized unsigned byte or short | texture coordinates |
COLOR_n | VEC3 or VEC4 | float, or normalized unsigned byte or short | linear RGB or RGBA multiplied with the material |
JOINTS_n | VEC4 | unsigned byte or short | indices into the skin’s joints |
WEIGHTS_n | VEC4 | float, or normalized unsigned byte or short | joint weights, adding up to 1 |
Sets are numbered from 0 without gaps (TEXCOORD_0,
TEXCOORD_1…). Application-specific attributes start with an underscore,
such as _TEMPERATURE. An extension may add attributes written
EXTENSION_NAME:ATTRIBUTE if it is in extensionsUsed. The
index is a decimal number from 0 to 999,999,999 without leading zeros (so
TEXCOORD_01 is invalid). JOINTS_n and WEIGHTS_n
come as a pair for each n, each pair giving four influences per vertex.
Weights are not negative and add up to exactly 1 for unsigned normalized storage
(about 1, within 2 × 10−7 per non-zero weight, for floats); joint
indices with non-zero weight are unique for a vertex and unused joints are 0.
All attribute accessors of a primitive have the same count. Float data
has no infinity or NaN, the tangent’s w is ±1 and COLOR_0 lies in 0 to 1.
Clients should support at least TEXCOORD_0, TEXCOORD_1,
COLOR_0 and JOINTS_0 with WEIGHTS_0.
Morph targets
Each target (an element of the primitive’s targets array, a flat map
like attributes) holds differences to add to the base attributes, scaled
by its weight. An attribute missing from a target means zero differences; an empty
target changes nothing. A target may only name attributes the primitive has, and its
accessors have as many elements as the base attributes. Every primitive of a mesh that
has targets has the same number of them (one without is read as all zeros). The
mesh’s weights, if present, has one number per target; if absent the
weights are 0. Many tools put target names in extras.targetNames; the
specification has no field for them. Clients should support POSITION,
NORMAL and TANGENT morphing.
| Name | Type | Components |
|---|---|---|
POSITION | VEC3 | float |
NORMAL | VEC3 | float |
TANGENT | VEC3 (no handedness) | float |
TEXCOORD_n | VEC2 | float, or normalized signed or unsigned byte or short |
COLOR_n | VEC3 or VEC4 | float, or normalized signed or unsigned byte or short |
Not described
What this page and the explorer leave out. All of it is defined by the Khronos glTF 2.0 specification, Google Draco and meshoptimizer.
Known, not yet covered
- Reference: the Draco and meshopt byte streams, and the byte layout rules for every matrix and component combination beyond those shown, are not described.
- Viewer: accessors in Draco or meshopt compressed data are decoded before they are read, so their values are in the Accessor values table and the pictures; a stream that does not decode is reported and its primitives are left out of the pictures. Buffers in separate files cannot be read from one dropped file.
- Viewer: sparse accessors were tested on built files only; no real file here uses them.