[osg-users] SSBO Instancing

David Heitbrink david-heitbrink at uiowa.edu
Wed Feb 27 09:26:53 PST 2019


I currently have a hardware instancing system that is setup for cars. I currently have the transform data stored in a TBO (texture buffer object). 

What I want to do is to change over to using a SSBO (shader storage buffer object), and to only copying the minimum amount of data I need per frame. Looking through the OSG code, I see glBufferSubData, is being used but I am not sure how I can specify the offset + size I want it to use, so I am not uploading the maximum size of my buffer every frame.

>From what I have read SSBOs are faster than TBOs, and I want to upload the minimum amount of data to the GPU each frame. 

So my question is, how can I specify the size of data to use every frame, instead of just updating the entire buffer? (FYI I am using OSG 3.6.3).  

Some background: 

For each car I have a proxy node that is a osg group setup with a bounding box, and position that matches the instanced car, and a cull call back to my buffer management system, that marks the object as "in view". 

Every frame I then compile my transform data. I have multiple cars objects that are being instanced, they are all sharing the same TBO. So for each model it gets a "base index" set via a uniform. So in the vertex shader the model matrix is fetched by taking "base index" + gl_InstanceID, then doing a little math to get the address, and doing 5 texelFetch calls to get model matrix + options.

This all works fine......except my buffer supports like 500+ cars, each car has multiple 4x5 matricies (4x4 model matrix +1 row for rendering options), each car has 2-18 wheels each with its own transform. I am doing a dirty every frame on my bound image, so it updates the entire image buffer, even if I only have like 2 cars in a view.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75665#75665







More information about the osg-users mailing list