Skip to content

Attribute and VAO locations

David Komer edited this page Jun 5, 2018 · 6 revisions

Attribute locations can theoretically be set manually (e.g. globally or per-renderer) or automatically (e.g. derived per-shader).

Therefore, vertex array objects can also be set manually (via createVertexArraysForRenderer) or automatically (via the createVertexArraysForShaders helper).

In GLTF it's done manually, because this allows uploading data as a separate step from the shader, as well as re-using attribute data across different shaders that would have otherwise given different indexes.

If using other shaders with Gltf, attributes must also be set manually otherwise they will conflict with gltf (haven't thoroughly tested this - but it makes sense...)

This is very simple to do, just append the new variable names to renderer.globalAttributeLocations before creating the shader, and use createVertexArrays for the vao. Since globalAttributeLocations is a Set it's safe to just blindly add the same attribute name for various different shaders without fear of a conflict.

Also - important note: vaos must be manually released after being activated, especially when combining shaders!

(they do not need to be released when assigning/setup)

Clone this wiki locally