Download

Example for a dynamically updated vertex buffer every frame?

Hello! I’m trying to create an effect with over 5,000 cards that update their position every frame. My naive implementation used Paper 2D Sprites, and it was breathtakingly slow. No surprise there. I switched to building something off of this example procedural mesh component (which is derived from CustomMeshComponent), which works better, but still is much slower than I would hope.

In digging through the code, instead of updating the vertex buffer, it recreates the vertex buffer every time you update it. Since I have a fixed number of cards, it seems like I should create the vertex buffer once with BUF_Dynamic (or BUF_Volatile?) and then lock it every frame to update the coordinates. In looking over the code, I’m not really clear how to do that since it seems like I can only modify it in the render thread.

Does anyone have any sample code that does this or something similar? Is there an easier way (something like glDrawArrays)?

Thank you so much for your help!