Separate VBO and BaseVertex

Hello !

I have some model in VBO ( ARRAY_BUFFER + ELEMENT_ARRAY_BUFFER ) and I’m using glMultiDrawElementsBaseVertex to render batched meshes at once. It works perfect. But I’d need another parallel VBO for bone ID and weights.

The main VBO is used to store packed vertex pos, norm, tangent, uv in [VNTU][VNTU]… form. Each mesh (and its submeshes) uses indices with indexes relative to first vertex of current group (each group indices starts with 0) and I’m using base vertex to seek in VBO to proper position - so many meshes can use the vary same VBO.

Question : Is it somehow posible to use another VBO and trick its base vertex so it could start seeking vertices attribs from different location than main VBO (maybe negative pointer addres that would overflow integer and seek to proper location in second VBO ?? ). For example :

Main VBO : _____xxxx______ ( starts in A )
                 ^ A
Bone VBO : xxxx___________ ( starts in 0 )
           ^ 0

and use for bone VBO : glVertexAttribPointer( … , (GLvoid)( -A ) ). So the pointer would look like 2^32 ( 2^64 in x64 ) - A. In the driver it would first add base vertex to the pointer using type size/stride and get pointer 0 at the end and then use VBO from the first element (if I thinks correctly). Does it have any sense for you ?

Currently I’m using specialized VBO for static meshes and animated ones so BoneID/Weight VBO will be in the same base vertex as the main vertex data.

I hope you could understand my point :wink: and thanks for any help.

No, unfortunately when I last checked (a year or 2 ago) it wasn’t possible to have negative values. I also wanted to do what you are trying previously, but for streaming certain attributes and not others. I ended up just streaming all the data.

A possible way that I considered would be to create a larger buffer with unused space (could be used for something unrelated) at the start so that your data starts part way through & the location it starts at is always greater than your max base_offset so that you can provide a pointer into this unused space so that when base_vertex is added you always end up at the same fixed location.

//fixed data starts at location X*attribute_size
glVertexAttribPointer(..., (X - base_offset)*attribute_size);
gl...Draw...BaseVertex(base_offset);

You have to keep calling glVertexAttribPointer every draw call anyway, so it sort of defeats the point of using BaseVertex draw calls & it’s much easier to just stream all the static data too.

Thats exactly what I thought. Using glVertexAttribPointer(…, (X - base_offset)*attribute_size); wont help becaouse of glMultiDraw…BaseVertex where is many different base vertexes. So I have to stay with current solution. Thanks for help.