0
\$\begingroup\$

What are the 16 attributes of a VAO?
0. vertex position
1. vertex colours
2. normal vector
3. texture coords
4. ???
5. ???
6. ???
7. ???
8. ???
9. ???
10. ???
11. ???
12. ???
13. ???
14. ???
15. ???

\$\endgroup\$
4
\$\begingroup\$

There are not 16 attributes with fixed meaning.

In old (pre 3.x) OpenGL there are a limited number of fixed function vertex attributes, and it is possible to use these in VAOs in compatibility contexts only. These correspond to generic vertex attribute (see the following discussion) slots as follows:

0: Position.
1: Vertex weight.
2: Normal.
3: Primary color.
4: Secondary color.
5: Fog coordinate.
8-15: Texture coordinates.

(Slots 6 and 7 have no corresponding fixed attribute).

The GL_ARB_vertex_program extension (from which this list comes) and OpenGL 2.0 introduced generic vertex attributes: these use the numbered slots only and they do not have any particular meaning. You can interpret the attribute any way that you wish in your shader code.

There are typically 16 of these generic attribute slots, numbered 0 to 15; newer GL_VERSIONs (and the associated hardware) may support more but you can rely on there being at least 16.

Where the correspondance I mentioned matters is if you are mixing fixed vertex attributes with generic vertex attributes in the same shader, and only in that case. So if you use the fixed Position and Normal attributes, for example, then slots 0 and 2 are not available for use by generic attributes in the same shader. If you're not using other fixed attributes then their slot numbers are available for use.

On the other hand, if you only use fixed attributes then you don't need to worry about slot numbers.

Likewise if you only use generic attributes (which is your only choice in core contexts) you can forget that the correspondance even exists. If you wish to use slot 2 for a texture coordinate and slot 4 for the airspeed velocity of an unladen swallow, you can.

So as you should be able to see, for the common cases where you're only using fixed attributes, or only using generic attributes, then none of this matters and you needn't be concerned with it. If on the other hand you're mixing fixed attributes with generic attributes, then you need to be aware of which slot numbers are or are not available for use.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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