简体   繁体   中英

Fast modification of OpenGL VAO buffers

I'm implementing a QT OpenGL application with a "timeline" that allows the user to scrub through some animated 3D geometry - ie scrubbing the timeline should trigger events that cause re-binding of VBO data so that it is re-drawn properly.

I could re-bind only the sections of memory that have changed between two time points on the timeline (aggregating all deltas between the two time points) but that seems pretty expensive. Would it suffice to naively just re-bind all VBO data on a time point change event, and keep track of all the VBO data for each frame in memory?

(I'm assuming here that you're animating vertices individually instead of using bones or something. The situation with bones would be similar.)

The problem is, having a full copy of the VBO for each frame is a ton of memory.

Ideally what you'd want to have is a list of keyframes that each have time, vertices that are animated by the keyframe as a list of vectors + offsets, and interpolation data. What you'd send to the vertex shader is a "before" VBO, and "after" VBO, an alpha. Then, the vertex shader does the interpolation.

That way, when you scrub to a point, you just have to glBufferSubData the parts of the before and after VBOs that are different (ie, each keyframe that you've passed, if any) and the glUniform1f the alpha. You can make some heuristic to avoid excessive glBufferSubData calls, ie re-send the whole buffer when you'd be doing more than, say, 5 calls.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM