1
$\begingroup$

I keep running into this phrase when reading specs and tutorials, but I have no idea what "tightly packed" is supposed to mean. Is it simply the opposite of an interleaved buffer? I.e. all the vertex data of a position attribute first, and then the normal attribute data sticked right after it? Or is it something else?

For instance, from the glTF spec:

If the accessor is used for any other kind of data (vertex indices, animation keyframes, etc.), its data elements are tightly packed.

$\endgroup$

1 Answer 1

2
$\begingroup$

To take an example from the glTF spec you cited:

The stride, in bytes, between vertex attributes. When this is not defined, data is tightly packed.

The stride of an array is the number of bytes from the start of one element to the start of the next element. If that stride is the same as the byte size of an element, then the array is "tightly packed". This means that there is no space between elements in the array; the byte after one element is the first byte of the next.

What this is saying is that, if you don't specify a stride, then the stride will be computed to be the size of the element type in question.

Interleaved vertex attributes are not "tightly packed" with respect to each other. If you have positions and normals interleaved, the position array is not tightly packed because the byte after one position is not the first byte of the next position.

However, you could consider it to be "tightly packed" with respect to an aggregation of the vertex data as a whole. If the byte after one position/normal combination is the first byte of another position/normal combination, then this could be said to be a "tightly packed" array of position/normal aggregates.

$\endgroup$
1
  • 2
    $\begingroup$ Another example of non-tightly packed would be a bitmap that uses 32 bits for each pixel but doesn't have an alpha channel (or at least doesn't use it). The extra byte could easily be completely unused padding. $\endgroup$ May 31, 2022 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.