Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Dynamic VBO content with multiple VBOs


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Ichi   Members   -  Reputation: 164

Like
0Likes
Like

Posted 08 April 2014 - 02:17 AM

Hello,

 

I'm new to this forum and instantly posting a problem. I hope you don't mind smile.png

 

I'm not about sharing you any code (because i haven't coded it, yet) but i want to know an efficient solution for following situation. I have multiple questions.

 

Since it's not possible to have multiple active VBOs at once i have to bind them over and over again and i have to bind all every tick which takes lots of time and is too slow in my opinion. The best way i guess is to create a single VBO with all information and use an IBO to seperate the information when drawing. 

 

My problem here is that I want to have dynamic content inside my VBOs for things which not have constant vertices like my map or maybe some models. Things could also be added or removed from my list of things i want to draw. How do i do this the best way? I mean i could bind a big VBO with all constant meshes and every dynamic VBO which are created every tick alone. The problem with this is that it would have to pass all information over and over again every tick which takes lots of time (i guess less than binding more small VBOs).

 

So is passing every VBO every tick the only solution since things may not get drawn always and other things may change their mesh?

Additionally i'd also have to pass every other information like normals and colors/uvs over and over again :/

 

Thanks a lot smile.png

Ichi


Edited by Ichi, 08 April 2014 - 02:22 AM.


Sponsor:

#2 TheChubu   Crossbones+   -  Reputation: 4782

Like
3Likes
Like

Posted 08 April 2014 - 06:57 AM


Since it's not possible to have multiple active VBOs at once
wut?

 

create VAO

bind VAO

    create buffer

    bind buffer

    add data to buffer

    create other buffer

    bind other buffer

    add other data to other buffer

 

Bam! Two VBOs at the same time with different data.

 

More seriously, what do you mean exactly by "multiple active VBOs at once" ? You can access multiple VBOs in the shader at the same time, or you're on the fixed function pipeline?


"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

 

My journals: dustArtemis ECS framework and Making a Terrain Generator


#3 Niteno Nish   Members   -  Reputation: 188

Like
0Likes
Like

Posted 08 April 2014 - 01:50 PM


So is passing every VBO every tick the only solution since things may not get drawn always and other things may change their mesh?
Additionally i'd also have to pass every other information like normals and colors/uvs over and over again :/

 

You can update the 'dynamic data' with glMapBufferRange, which obviously is much faster then reloading the entire buffer with glBufferData. 
 
I am not sure what you mean by dynamic data, is it objects that are to be animated?  In which case rather then reloading the vertices again, you should use transformation matrix inside vertex shader and similarly you can animate textures inside vertex shader or in fragment shader.


#4 Ichi   Members   -  Reputation: 164

Like
0Likes
Like

Posted 09 April 2014 - 11:09 AM

Thanks you for youre comments smile.png

 

create VAO

bind VAO

    create buffer

    bind buffer

    add data to buffer

    create other buffer

    bind other buffer

    add other data to other buffer

 

 

Sorry for this topic. I have no idea why I thought I couldn't bind multiple vbos for different models.

I have done it just like you wrote and everything works fine. Thanks to the vao buffer drawing requiers way less code.

If i do this for multiple models all data will stay inside my videocard right?

 

If so how do I delete that information correctly?

is glDeleteVertexArrays(1, VAO) enough or do i also have to glDeleteBuffers(1, VBO) for all vbos?

 

 

 

 


So is passing every VBO every tick the only solution since things may not get drawn always and other things may change their mesh?
Additionally i'd also have to pass every other information like normals and colors/uvs over and over again :/
 

 

You can update the 'dynamic data' with glMapBufferRange, which obviously is much faster then reloading the entire buffer with glBufferData. 
 
I am not sure what you mean by dynamic data, is it objects that are to be animated?  In which case rather then reloading the vertices again, you should use transformation matrix inside vertex shader and similarly you can animate textures inside vertex shader or in fragment shader.

 

 

What I mean with dynamic data is for example a voxel based world with changing content. And for animations which are not changing the model's scale, rotation or position but for example for a walking animal animation i'd also have to change vertices i guess. didnt look at how to animate things yet


Edited by Ichi, 09 April 2014 - 12:01 PM.


#5 mhagain   Crossbones+   -  Reputation: 8281

Like
1Likes
Like

Posted 09 April 2014 - 01:21 PM

And for animations which are not changing the model's scale, rotation or position but for example for a walking animal animation i'd also have to change vertices i guess. didnt look at how to animate things yet

 

No, you can do this in a vertex shader.  For simple keyframe animation you don't even need a vertex shader; you just have a single VBO for your model which contains data for all frames, then in your glVertexAttribPointer call you set the offsets for the current frame.  For interpolated keyframes you use a single VBO but two glVertexAttribPointer calls - offset for previous frame and current frame - then send the blend factor as a uniform, and do the blending in a vertex shader.  For skeletal animation you have the basic frame data in a VBO then send the bone matrices as uniforms, indexing into the uniform array according to the blendindex for each vertex.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS