Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Separate VBO and BaseVertex

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2009
    Location
    Poland
    Posts
    16

    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 :

    Code :
    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 and thanks for any help.

  2. #2
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    456
    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.

    Code :
    //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.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2009
    Location
    Poland
    Posts
    16
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •